blob: 894947410bfae8330937a3fbd44558e23677323c [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 Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/** ------------------------------------------------------------------------ *
31 ------------------------------------------------------------------------ *
32
33
34 \file wlan_hdd_wext.c
35
36 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
37 interfaces.
38
39 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041 This file defines all of the types that are utilized by the CCP module
42 of the "Portable" HDD. This file also includes the underlying Linux
43 Wireless Extensions Data types referred to by CCP.
44
45 ======================================================================== */
46
47#include <linux/version.h>
48#include <linux/module.h>
49#include <linux/kernel.h>
50#include <linux/init.h>
51#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053052#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include <wlan_hdd_includes.h>
54#include <wlan_btc_svc.h>
55#include <wlan_nlink_common.h>
56#ifdef WLAN_BTAMP_FEATURE
57#include <bap_hdd_main.h>
58#endif
59#include <vos_api.h>
60#include <net/arp.h>
61#include "ccmApi.h"
62#include "sirParams.h"
63#include "csrApi.h"
64#include "csrInsideApi.h"
65#if defined WLAN_FEATURE_VOWIFI
66#include "smeRrmInternal.h"
67#endif
68#include <aniGlobal.h>
69#include "dot11f.h"
70#include <wlan_hdd_wowl.h>
71#include <wlan_hdd_cfg.h>
72#include <wlan_hdd_wmm.h>
73#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053075#ifdef FEATURE_WLAN_TDLS
76#include "wlan_hdd_tdls.h"
77#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070078
79#ifdef CONFIG_HAS_EARLYSUSPEND
80#include <linux/earlysuspend.h>
81#endif
82#include "wlan_hdd_power.h"
83#include "qwlan_version.h"
84#include <vos_power.h>
85#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
105#ifdef CONFIG_HAS_EARLYSUSPEND
106extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
107extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
108#endif
109
Jeff Johnsone7245742012-09-05 17:12:55 -0700110#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800111#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700112#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700113
114#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530115#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700119static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122/* To Validate Channel against the Frequency and Vice-Versa */
123static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
124 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
125 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
126 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
127 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
128 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
129 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
130 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800131 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
132 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800134#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136/* Private ioctls and their sub-ioctls */
137#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
138#define WE_SET_11D_STATE 1
139#define WE_WOWL 2
140#define WE_SET_POWER 3
141#define WE_SET_MAX_ASSOC 4
142#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
143#define WE_SET_DATA_INACTIVITY_TO 6
144#define WE_SET_MAX_TX_POWER 7
145#define WE_SET_HIGHER_DTIM_TRANSITION 8
146#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530147#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700148#define WE_SET_MAX_TX_POWER_2_4 11
149#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800150/* Private IOCTL for debug connection issues */
151#define WE_SET_DEBUG_LOG 13
Jeff Johnson295189b2012-06-20 16:38:30 -0700152
153/* Private ioctls and their sub-ioctls */
154#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
155#define WE_GET_11D_STATE 1
156#define WE_IBSS_STATUS 2
157#define WE_PMC_STATE 3
158#define WE_GET_WLAN_DBG 4
159#define WE_MODULE_DOWN_IND 5
160#define WE_GET_MAX_ASSOC 6
161#define WE_GET_WDI_DBG 7
162#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
163#define WE_GET_CONCURRENCY_MODE 9
164/* Private ioctls and their sub-ioctls */
165#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
166
167/* Private ioctls and their sub-ioctls */
168#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
169#define WE_WOWL_ADD_PTRN 1
170#define WE_WOWL_DEL_PTRN 2
171#if defined WLAN_FEATURE_VOWIFI
172#define WE_NEIGHBOR_REPORT_REQUEST 3
173#endif
174#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
175#define WE_SET_CONFIG 5
176
177/* Private ioctls and their sub-ioctls */
178#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
179#define WE_SET_WLAN_DBG 1
180#define WE_SET_WDI_DBG 2
181#define WE_SET_SAP_CHANNELS 3
182
183/* Private ioctls and their sub-ioctls */
184#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
185#define WE_WLAN_VERSION 1
186#define WE_GET_STATS 2
187#define WE_GET_CFG 3
188#define WE_GET_WMM_STATUS 4
189#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700190#ifdef WLAN_FEATURE_11AC
191#define WE_GET_RSSI 6
192#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800193#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800194#ifdef FEATURE_WLAN_TDLS
195#define WE_GET_TDLS_PEERS 8
196#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700197#ifdef WLAN_FEATURE_11W
198#define WE_GET_11W_INFO 9
199#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530200#define WE_GET_STATES 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202/* Private ioctls and their sub-ioctls */
203#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
204#define WE_CLEAR_STATS 1
205#define WE_INIT_AP 2
206#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530207#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700208#define WE_ENABLE_AMP 4
209#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530210#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700211#define WE_ENABLE_DXE_STALL_DETECT 6
212#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700213#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530214#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530215#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700216
217/* Private ioctls and their sub-ioctls */
218#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
219#define WE_LOG_DUMP_CMD 1
220
Jeff Johnson295189b2012-06-20 16:38:30 -0700221#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800222//IOCTL to configure MCC params
223#define WE_MCC_CONFIG_CREDENTIAL 3
224#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
Chilam NG571c65a2013-01-19 12:27:36 +0530226#ifdef FEATURE_WLAN_TDLS
227#define WE_TDLS_CONFIG_PARAMS 5
228#endif
229
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700230#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530231#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700232
Chilam Ng01120412013-02-19 18:32:21 -0800233#ifdef FEATURE_WLAN_TDLS
234#undef MAX_VAR_ARGS
235#define MAX_VAR_ARGS 10
236#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700237#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800238#endif
239
Jeff Johnson295189b2012-06-20 16:38:30 -0700240
241/* Private ioctls (with no sub-ioctls) */
242/* note that they must be odd so that they have "get" semantics */
243#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
244#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
245#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
246
Girish Gowli464c9c82014-06-09 19:47:53 +0530247/* (SIOCIWFIRSTPRIV + 8) is currently unused */
248/* (SIOCIWFIRSTPRIV + 16) is currently unused */
249/* (SIOCIWFIRSTPRIV + 10) is currently unused */
250/* (SIOCIWFIRSTPRIV + 12) is currently unused */
251/* (SIOCIWFIRSTPRIV + 14) is currently unused */
252/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700253
Jeff Johnsone7245742012-09-05 17:12:55 -0700254#ifdef FEATURE_OEM_DATA_SUPPORT
255/* Private ioctls for setting the measurement configuration */
256#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
257#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
258#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700259
260#ifdef WLAN_FEATURE_VOWIFI_11R
261#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
262#endif
263
264/* Private ioctl for setting the host offload feature */
265#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
266
267/* Private ioctl to get the statistics */
268#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
269
270/* Private ioctl to set the Keep Alive Params */
271#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
272#ifdef WLAN_FEATURE_PACKET_FILTERING
273/* Private ioctl to set the Packet Filtering Params */
274#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
275#endif
276
277#ifdef FEATURE_WLAN_SCAN_PNO
278/* Private ioctl to get the statistics */
279#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
280#endif
281
282#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
283
284#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
285#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700286/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700287
Jeff Johnson295189b2012-06-20 16:38:30 -0700288#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
289#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
290
291#define WLAN_STATS_INVALID 0
292#define WLAN_STATS_RETRY_CNT 1
293#define WLAN_STATS_MUL_RETRY_CNT 2
294#define WLAN_STATS_TX_FRM_CNT 3
295#define WLAN_STATS_RX_FRM_CNT 4
296#define WLAN_STATS_FRM_DUP_CNT 5
297#define WLAN_STATS_FAIL_CNT 6
298#define WLAN_STATS_RTS_FAIL_CNT 7
299#define WLAN_STATS_ACK_FAIL_CNT 8
300#define WLAN_STATS_RTS_SUC_CNT 9
301#define WLAN_STATS_RX_DISCARD_CNT 10
302#define WLAN_STATS_RX_ERROR_CNT 11
303#define WLAN_STATS_TX_BYTE_CNT 12
304
305#define WLAN_STATS_RX_BYTE_CNT 13
306#define WLAN_STATS_RX_RATE 14
307#define WLAN_STATS_TX_RATE 15
308
Jeff Johnsone7245742012-09-05 17:12:55 -0700309#define WLAN_STATS_RX_UC_BYTE_CNT 16
310#define WLAN_STATS_RX_MC_BYTE_CNT 17
311#define WLAN_STATS_RX_BC_BYTE_CNT 18
312#define WLAN_STATS_TX_UC_BYTE_CNT 19
313#define WLAN_STATS_TX_MC_BYTE_CNT 20
314#define WLAN_STATS_TX_BC_BYTE_CNT 21
315
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800316#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
317 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
318 { \
319 *__p++ = __type; \
320 *__p++ = __size; \
321 memcpy(__p, __val, __size); \
322 __p += __size; \
323 __tlen += __size + 2; \
324 } \
325 else \
326 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800327 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800328 } \
329 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700330
331#define VERSION_VALUE_MAX_LEN 32
332
333#define TX_PER_TRACKING_DEFAULT_RATIO 5
334#define TX_PER_TRACKING_MAX_RATIO 10
335#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
336
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530337#define WLAN_ADAPTER 0
338#define P2P_ADAPTER 1
339
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800340/*MCC Configuration parameters */
341enum {
342 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
343 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
344 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
345 MCC_RX_DRAIN_TIME_CFG_PARAM,
346 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
347 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
348 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
349 MCC_MIN_AFTER_DTIM_CFG_PARAM,
350 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
351};
352
353int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
354 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
355
Jeff Johnson295189b2012-06-20 16:38:30 -0700356#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800357int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700358 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700359#endif
360
Jeff Johnson295189b2012-06-20 16:38:30 -0700361/**---------------------------------------------------------------------------
362
Arif Hussain0273cba2014-01-07 20:58:29 -0800363 \brief mem_alloc_copy_from_user_helper -
364
365 Helper function to allocate buffer and copy user data.
366
367 \param - wrqu - Pointer to IOCTL Data.
368 len - size
369
370 \return - On Success pointer to buffer, On failure NULL
371
372 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530373void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800374{
375 u8 *ptr = NULL;
376
377 /* in order to protect the code, an extra byte is post appended to the buffer
378 * and the null termination is added. However, when allocating (len+1) byte
379 * of memory, we need to make sure that there is no uint overflow when doing
380 * addition. In theory check len < UINT_MAX protects the uint overflow. For
381 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
382 * guess, now, it is assumed that the private command buffer size is no
383 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
384 */
385 if (len > MAX_USER_COMMAND_SIZE)
386 {
387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
388 "Invalid length");
389 return NULL;
390 }
391
392 ptr = kmalloc(len + 1, GFP_KERNEL);
393 if (NULL == ptr)
394 {
395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
396 "unable to allocate memory");
397 return NULL;
398 }
399
400 if (copy_from_user(ptr, wrqu_data, len))
401 {
402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
403 "%s: failed to copy data to user buffer", __func__);
404 kfree(ptr);
405 return NULL;
406 }
407 ptr[len] = '\0';
408 return ptr;
409}
410
Girish Gowli488ef492014-06-12 18:44:33 +0530411// Function to handle and get compatible struct iw_point passed to ioctl.
412int hdd_priv_get_data(struct iw_point *p_priv_data,
413 union iwreq_data *wrqu)
414{
415 if ((NULL == p_priv_data) || (NULL == wrqu))
416 {
417 return -EINVAL;
418 }
419
420#ifdef CONFIG_COMPAT
421 if (is_compat_task())
422 {
423 struct compat_iw_point *p_compat_priv_data;
424
425 // Compat task: typecast to campat structure and copy the members.
426 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
427
428 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
429 p_priv_data->length = p_compat_priv_data->length;
430 p_priv_data->flags = p_compat_priv_data->flags;
431 }//if(is_compat_task())
432 else
433 {
434#endif //#ifdef CONFIG_COMPAT
435
436 // Non compat task: directly copy the structure.
437 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
438
439#ifdef CONFIG_COMPAT
440 }//else of - if(is_compat_task())
441#endif //#ifdef CONFIG_COMPAT
442
443 return 0;
444}
445
Arif Hussain0273cba2014-01-07 20:58:29 -0800446/**---------------------------------------------------------------------------
447
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 \brief hdd_wlan_get_version() -
449
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800450 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700451
452 \param - pAdapter Pointer to the adapter.
453 wrqu - Pointer to IOCTL REQUEST Data.
454 extra - Pointer to char
455
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800456 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700457
458 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800459void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
460 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700461{
462 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800463 tSirVersionString wcnss_SW_version;
464 tSirVersionString wcnss_HW_version;
465 char *pSWversion;
466 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800469 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
470 sizeof(wcnss_SW_version));
471 if (VOS_IS_STATUS_SUCCESS(status))
472 {
473 pSWversion = wcnss_SW_version;
474 }
475 else
476 {
477 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 }
479
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800480 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
481 sizeof(wcnss_HW_version));
482 if (VOS_IS_STATUS_SUCCESS(status))
483 {
484 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800486 else
487 {
488 pHWversion = "Unknown";
489 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700490
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700491 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800492 "Host SW:%s, FW:%s, HW:%s",
493 QWLAN_VERSIONSTR,
494 pSWversion,
495 pHWversion);
496
497 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700498}
499
Jeff Johnson295189b2012-06-20 16:38:30 -0700500int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
501{
502 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
503 v_U32_t threshold = 0,status = 0;
504
505 ENTER();
506
Agarwal Ashish971c2882013-10-30 20:11:12 +0530507 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
508 {
509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 "%s:LOGP in Progress. Ignore!!!",__func__);
511 return status;
512 }
513
514 if ( eHAL_STATUS_SUCCESS !=
515 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
516 {
c_hpothub8245442013-11-20 23:41:09 +0530517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
518 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 return -EIO;
520 }
521 wrqu->rts.value = threshold;
522
523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800524 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700525
526 EXIT();
527
528 return 0;
529}
530
531int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
532{
533 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
534 v_U32_t threshold = 0,status = 0;
535
536 ENTER();
537
Agarwal Ashish971c2882013-10-30 20:11:12 +0530538 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
539 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
541 "%s:LOGP in Progress. Ignore!!!",__func__);
542 return status;
543 }
544
545 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
546 != eHAL_STATUS_SUCCESS )
547 {
c_hpothub8245442013-11-20 23:41:09 +0530548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
549 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 return -EIO;
551 }
552 wrqu->frag.value = threshold;
553
554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800555 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700556
557 EXIT();
558
559 return 0;
560}
561
562int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
563{
Jeff Johnsone7245742012-09-05 17:12:55 -0700564 int i;
565 if (channel > 0)
566 {
567 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
568 {
569 if (channel == freq_chan_map[i].chan)
570 {
571 *pfreq = freq_chan_map[i].freq;
572 return 1;
573 }
574 }
575 }
576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800577 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700578 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700579}
580
581static v_BOOL_t
582hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
583{
584 v_BOOL_t rsnType = VOS_FALSE;
585 // is the authType supported?
586 switch (authType)
587 {
588 case eCSR_AUTH_TYPE_NONE: //never used
589 rsnType = eANI_BOOLEAN_FALSE;
590 break;
591 // MAC layer authentication types
592 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
593 rsnType = eANI_BOOLEAN_FALSE;
594 break;
595 case eCSR_AUTH_TYPE_SHARED_KEY:
596 rsnType = eANI_BOOLEAN_FALSE;
597 break;
598 case eCSR_AUTH_TYPE_AUTOSWITCH:
599 rsnType = eANI_BOOLEAN_FALSE;
600 break;
601
602 // Upper layer authentication types
603 case eCSR_AUTH_TYPE_WPA:
604 rsnType = eANI_BOOLEAN_TRUE;
605 break;
606 case eCSR_AUTH_TYPE_WPA_PSK:
607 rsnType = eANI_BOOLEAN_TRUE;
608 break;
609 case eCSR_AUTH_TYPE_WPA_NONE:
610 rsnType = eANI_BOOLEAN_TRUE;
611 break;
612#ifdef WLAN_FEATURE_VOWIFI_11R
613 case eCSR_AUTH_TYPE_FT_RSN:
614#endif
615 case eCSR_AUTH_TYPE_RSN:
616 rsnType = eANI_BOOLEAN_TRUE;
617 break;
618#ifdef WLAN_FEATURE_VOWIFI_11R
619 case eCSR_AUTH_TYPE_FT_RSN_PSK:
620#endif
621 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700622#ifdef WLAN_FEATURE_11W
623 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
624#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 rsnType = eANI_BOOLEAN_TRUE;
626 break;
627 //case eCSR_AUTH_TYPE_FAILED:
628 case eCSR_AUTH_TYPE_UNKNOWN:
629 rsnType = eANI_BOOLEAN_FALSE;
630 break;
631 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800632 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
633 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 rsnType = eANI_BOOLEAN_FALSE;
635 break;
636 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800637 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700638 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 return rsnType;
640}
641
642static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
643{
644 struct statsContext *pStatsContext;
645 hdd_adapter_t *pAdapter;
646
647 if (ioctl_debug)
648 {
649 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700650 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 }
652
653 if (NULL == pContext)
654 {
655 hddLog(VOS_TRACE_LEVEL_ERROR,
656 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700657 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 return;
659 }
660
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 pStatsContext = pContext;
662 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800663
664 /* there is a race condition that exists between this callback
665 function and the caller since the caller could time out either
666 before or while this code is executing. we use a spinlock to
667 serialize these actions */
668 spin_lock(&hdd_context_lock);
669
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
671 {
672 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800673 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 hddLog(VOS_TRACE_LEVEL_WARN,
675 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700676 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 if (ioctl_debug)
678 {
679 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700680 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 }
682 return;
683 }
684
Jeff Johnson72a40512013-12-19 10:14:15 -0800685 /* context is valid so caller is still waiting */
686
687 /* paranoia: invalidate the magic */
688 pStatsContext->magic = 0;
689
690 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 pAdapter->rssi = rssi;
692
Jeff Johnson72a40512013-12-19 10:14:15 -0800693 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800695
696 /* serialization is complete */
697 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700698}
699
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530700static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
701{
702 struct statsContext *pStatsContext;
703 hdd_adapter_t *pAdapter;
704
705 if (ioctl_debug)
706 {
707 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
708 __func__, (int)snr, (int)staId, pContext);
709 }
710
711 if (NULL == pContext)
712 {
713 hddLog(VOS_TRACE_LEVEL_ERROR,
714 "%s: Bad param, pContext [%p]",
715 __func__, pContext);
716 return;
717 }
718
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530719 pStatsContext = pContext;
720 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800721
722 /* there is a race condition that exists between this callback
723 function and the caller since the caller could time out either
724 before or while this code is executing. we use a spinlock to
725 serialize these actions */
726 spin_lock(&hdd_context_lock);
727
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530728 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
729 {
730 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800731 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530732 hddLog(VOS_TRACE_LEVEL_WARN,
733 "%s: Invalid context, pAdapter [%p] magic [%08x]",
734 __func__, pAdapter, pStatsContext->magic);
735 if (ioctl_debug)
736 {
737 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
738 __func__, pAdapter, pStatsContext->magic);
739 }
740 return;
741 }
742
Jeff Johnson72a40512013-12-19 10:14:15 -0800743 /* context is valid so caller is still waiting */
744
745 /* paranoia: invalidate the magic */
746 pStatsContext->magic = 0;
747
748 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530749 pAdapter->snr = snr;
750
Jeff Johnson72a40512013-12-19 10:14:15 -0800751 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530752 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800753
754 /* serialization is complete */
755 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530756}
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
759{
760 struct statsContext context;
761 hdd_context_t *pHddCtx;
762 hdd_station_ctx_t *pHddStaCtx;
763 eHalStatus hstatus;
764 long lrc;
765
766 if (NULL == pAdapter)
767 {
768 hddLog(VOS_TRACE_LEVEL_WARN,
769 "%s: Invalid context, pAdapter", __func__);
770 return VOS_STATUS_E_FAULT;
771 }
772 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
773 {
774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
775 /* return a cached value */
776 *rssi_value = pAdapter->rssi;
777 return VOS_STATUS_SUCCESS;
778 }
779
780 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
781 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
782
783 init_completion(&context.completion);
784 context.pAdapter = pAdapter;
785 context.magic = RSSI_CONTEXT_MAGIC;
786
787 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
788 pHddStaCtx->conn_info.staId[ 0 ],
789 pHddStaCtx->conn_info.bssId,
790 &context, pHddCtx->pvosContext);
791 if (eHAL_STATUS_SUCCESS != hstatus)
792 {
793 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700794 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 /* we'll returned a cached value below */
796 }
797 else
798 {
799 /* request was sent -- wait for the response */
800 lrc = wait_for_completion_interruptible_timeout(&context.completion,
801 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 if (lrc <= 0)
803 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700805 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 /* we'll now returned a cached value below */
807 }
808 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800809
810 /* either we never sent a request, we sent a request and received a
811 response or we sent a request and timed out. if we never sent a
812 request or if we sent a request and got a response, we want to
813 clear the magic out of paranoia. if we timed out there is a
814 race condition such that the callback function could be
815 executing at the same time we are. of primary concern is if the
816 callback function had already verified the "magic" but had not
817 yet set the completion variable when a timeout occurred. we
818 serialize these activities by invalidating the magic while
819 holding a shared spinlock which will cause us to block if the
820 callback is currently executing */
821 spin_lock(&hdd_context_lock);
822 context.magic = 0;
823 spin_unlock(&hdd_context_lock);
824
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 *rssi_value = pAdapter->rssi;
826
827 return VOS_STATUS_SUCCESS;
828}
829
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530830VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
831{
832 struct statsContext context;
833 hdd_context_t *pHddCtx;
834 hdd_station_ctx_t *pHddStaCtx;
835 eHalStatus hstatus;
836 long lrc;
837 int valid;
838
839 if (NULL == pAdapter)
840 {
841 hddLog(VOS_TRACE_LEVEL_ERROR,
842 "%s: Invalid context, pAdapter", __func__);
843 return VOS_STATUS_E_FAULT;
844 }
845
846 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
847
848 valid = wlan_hdd_validate_context(pHddCtx);
849 if (0 != valid)
850 {
851 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
852 return VOS_STATUS_E_FAULT;
853 }
854
855 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
856 if (NULL == pHddStaCtx)
857 {
858 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
859 return VOS_STATUS_E_FAULT;
860 }
861
862 init_completion(&context.completion);
863 context.pAdapter = pAdapter;
864 context.magic = SNR_CONTEXT_MAGIC;
865
866 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
867 pHddStaCtx->conn_info.staId[ 0 ],
868 pHddStaCtx->conn_info.bssId,
869 &context);
870 if (eHAL_STATUS_SUCCESS != hstatus)
871 {
872 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
873 __func__);
874 /* we'll returned a cached value below */
875 }
876 else
877 {
878 /* request was sent -- wait for the response */
879 lrc = wait_for_completion_interruptible_timeout(&context.completion,
880 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530881 if (lrc <= 0)
882 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800883 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530884 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530885 /* we'll now returned a cached value below */
886 }
887 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800888
889 /* either we never sent a request, we sent a request and received a
890 response or we sent a request and timed out. if we never sent a
891 request or if we sent a request and got a response, we want to
892 clear the magic out of paranoia. if we timed out there is a
893 race condition such that the callback function could be
894 executing at the same time we are. of primary concern is if the
895 callback function had already verified the "magic" but had not
896 yet set the completion variable when a timeout occurred. we
897 serialize these activities by invalidating the magic while
898 holding a shared spinlock which will cause us to block if the
899 callback is currently executing */
900 spin_lock(&hdd_context_lock);
901 context.magic = 0;
902 spin_unlock(&hdd_context_lock);
903
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530904 *snr = pAdapter->snr;
905
906 return VOS_STATUS_SUCCESS;
907}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800908#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800909
910static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
911{
912 struct statsContext *pStatsContext;
913 hdd_adapter_t *pAdapter;
914 if (ioctl_debug)
915 {
916 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
917 __func__, (int)rssi, (int)staId, pContext);
918 }
919
920 if (NULL == pContext)
921 {
922 hddLog(VOS_TRACE_LEVEL_ERROR,
923 "%s: Bad param, pContext [%p]",
924 __func__, pContext);
925 return;
926 }
927
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800928 pStatsContext = pContext;
929 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800930
931 /* there is a race condition that exists between this callback
932 function and the caller since the caller could time out either
933 before or while this code is executing. we use a spinlock to
934 serialize these actions */
935 spin_lock(&hdd_context_lock);
936
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800937 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
938 {
939 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800940 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800941 hddLog(VOS_TRACE_LEVEL_WARN,
942 "%s: Invalid context, pAdapter [%p] magic [%08x]",
943 __func__, pAdapter, pStatsContext->magic);
944 if (ioctl_debug)
945 {
946 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
947 __func__, pAdapter, pStatsContext->magic);
948 }
949 return;
950 }
951
Jeff Johnson72a40512013-12-19 10:14:15 -0800952 /* context is valid so caller is still waiting */
953
954 /* paranoia: invalidate the magic */
955 pStatsContext->magic = 0;
956
957 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800958 pAdapter->rssi = rssi;
959
Jeff Johnson72a40512013-12-19 10:14:15 -0800960 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800961 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800962
963 /* serialization is complete */
964 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800965}
966
967
968
969VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
970{
971 struct statsContext context;
972 hdd_context_t *pHddCtx = NULL;
973 hdd_station_ctx_t *pHddStaCtx = NULL;
974 eHalStatus hstatus;
975 long lrc;
976
977 if (NULL == pAdapter)
978 {
979 hddLog(VOS_TRACE_LEVEL_WARN,
980 "%s: Invalid context, pAdapter", __func__);
981 return VOS_STATUS_E_FAULT;
982 }
983 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
984 {
985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
986 /* return a cached value */
987 *rssi_value = pAdapter->rssi;
988 return VOS_STATUS_SUCCESS;
989 }
990
991 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
992 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
993
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +0530994 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800995 {
996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
997 /* return a cached value */
998 *rssi_value = 0;
999 return VOS_STATUS_SUCCESS;
1000 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301001
1002 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1003 {
1004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1005 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1006 *rssi_value = pAdapter->rssi;
1007 return VOS_STATUS_SUCCESS;
1008 }
1009
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001010 init_completion(&context.completion);
1011 context.pAdapter = pAdapter;
1012 context.magic = RSSI_CONTEXT_MAGIC;
1013
1014 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1015 pHddStaCtx->conn_info.staId[ 0 ],
1016 pHddStaCtx->conn_info.bssId,
1017 &context, pHddCtx->pvosContext);
1018 if (eHAL_STATUS_SUCCESS != hstatus)
1019 {
1020 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1021 __func__);
1022 /* we'll returned a cached value below */
1023 }
1024 else
1025 {
1026 /* request was sent -- wait for the response */
1027 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1028 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001029 if (lrc <= 0)
1030 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001031 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001032 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001033 /* we'll now returned a cached value below */
1034 }
1035 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001036
1037 /* either we never sent a request, we sent a request and received a
1038 response or we sent a request and timed out. if we never sent a
1039 request or if we sent a request and got a response, we want to
1040 clear the magic out of paranoia. if we timed out there is a
1041 race condition such that the callback function could be
1042 executing at the same time we are. of primary concern is if the
1043 callback function had already verified the "magic" but had not
1044 yet set the completion variable when a timeout occurred. we
1045 serialize these activities by invalidating the magic while
1046 holding a shared spinlock which will cause us to block if the
1047 callback is currently executing */
1048 spin_lock(&hdd_context_lock);
1049 context.magic = 0;
1050 spin_unlock(&hdd_context_lock);
1051
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001052 *rssi_value = pAdapter->rssi;
1053
1054 return VOS_STATUS_SUCCESS;
1055}
1056#endif
1057
1058
Jeff Johnson295189b2012-06-20 16:38:30 -07001059void hdd_StatisticsCB( void *pStats, void *pContext )
1060{
1061 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1062 hdd_stats_t *pStatsCache = NULL;
1063 hdd_wext_state_t *pWextState;
1064 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1065
1066 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1067 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1068 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1069 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1070 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1071 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1072
1073 if (pAdapter!= NULL)
1074 pStatsCache = &pAdapter->hdd_stats;
1075
1076
1077 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1078 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1079 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1080 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1081 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1082 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1083
1084 if (pStatsCache!=NULL)
1085 {
1086 // and copy the stats into the cache we keep in the adapter instance structure
1087 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1088 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1089 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1090 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1091 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1092 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1093 }
1094
1095 if(pAdapter)
1096 {
1097 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1098 if(pWextState)
1099 {
1100 vos_status = vos_event_set(&pWextState->vosevent);
1101 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1102 {
1103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001104 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 return;
1106 }
1107 }
1108 }
1109}
1110
1111void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1112{
1113 v_CONTEXT_t pVosContext;
1114 hdd_context_t *pHddCtx;
1115 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1116#if 0
1117 hdd_wext_state_t *pWextState;
1118 v_U32_t roamId;
1119#endif
1120
1121 ENTER();
1122
1123 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1124
1125 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1126 if (NULL == pHddCtx)
1127 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001128 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001129 return;
1130 }
1131#if 0
1132 pWextState = pAdapter->pWextState;
1133#endif
1134
1135 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1136 {
1137 //TODO Verify is this is really used. If yes need to fix it.
1138 hdd_reconnect_all_adapters( pHddCtx );
1139#if 0
1140 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1141 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1142 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1143
1144 if(VOS_STATUS_SUCCESS == vosStatus)
1145 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1146 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1147
1148 sme_RoamConnect(halHandle,
1149 pAdapter->sessionId, &(pWextState->roamProfile),
1150 &roamId);
1151#endif
1152 }
1153
1154 EXIT();
1155
1156}
1157
1158void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1159{
1160 int i = 0;
1161 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1162
1163 /* clear WPA/RSN/WSC IE information in the profile */
1164 pWextState->roamProfile.nWPAReqIELength = 0;
1165 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1166 pWextState->roamProfile.nRSNReqIELength = 0;
1167 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1168
Chet Lanctot186b5732013-03-18 10:26:30 -07001169#ifdef FEATURE_WLAN_WAPI
1170 pWextState->roamProfile.nWAPIReqIELength = 0;
1171 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1172#endif
1173
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001175 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301177 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1179 pWextState->roamProfile.nAddIEAssocLength = 0;
1180
1181 pWextState->roamProfile.EncryptionType.numEntries = 1;
1182 pWextState->roamProfile.EncryptionType.encryptionType[0]
1183 = eCSR_ENCRYPT_TYPE_NONE;
1184
1185 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1186 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1187 = eCSR_ENCRYPT_TYPE_NONE;
1188
1189 pWextState->roamProfile.AuthType.numEntries = 1;
1190 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1191
Chet Lanctot186b5732013-03-18 10:26:30 -07001192#ifdef WLAN_FEATURE_11W
1193 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1194 pWextState->roamProfile.MFPRequired = 0;
1195 pWextState->roamProfile.MFPCapable = 0;
1196#endif
1197
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 pWextState->authKeyMgmt = 0;
1199
1200 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1201 {
1202 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1203 {
1204 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1205 }
1206 }
1207#ifdef FEATURE_WLAN_WAPI
1208 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1209 pAdapter->wapi_info.nWapiMode = 0;
1210#endif
1211
1212 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1213
1214}
1215
1216void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1217{
1218 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001219
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001220 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1221 {
1222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1223 "%s: Invalid pAdapter magic", __func__);
1224 }
1225 else
1226 {
1227 complete(&pAdapter->ula_complete);
1228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001229}
1230
1231VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1232{
1233 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001235 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001236
1237 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1238 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001239 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001240
1241 /*To avoid race condition between the set key and the last EAPOL
1242 packet, notify TL to finish upper layer authentication incase if the
1243 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001244 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001245
1246 if ( vos_status != VOS_STATUS_SUCCESS )
1247 {
1248 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1249 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1250 __LINE__, vos_status );
1251 return vos_status;
1252
1253 }
1254
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001255 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301257 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001258 {
1259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301260 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001261 /* we'll still fall through and return success since the
1262 * connection may still get established but is just taking
1263 * too long for us to wait */
1264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 }
1266 return VOS_STATUS_SUCCESS;
1267}
1268
1269v_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)
1270{
1271
1272 int left = ie_len;
1273 v_U8_t *ptr = ie;
1274 v_U8_t elem_id,elem_len;
1275 v_U8_t eid = 0xDD;
1276
1277 if ( NULL == ie || 0 == ie_len )
1278 return NULL;
1279
1280 while(left >= 2)
1281 {
1282 elem_id = ptr[0];
1283 elem_len = ptr[1];
1284 left -= 2;
1285 if(elem_len > left)
1286 {
1287 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001288 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 eid,elem_len,left);
1290 return NULL;
1291 }
1292 if (elem_id == eid)
1293 {
1294 if(memcmp( &ptr[2], oui, oui_size)==0)
1295 return ptr;
1296 }
1297
1298 left -= elem_len;
1299 ptr += (elem_len + 2);
1300 }
1301 return NULL;
1302}
1303
1304static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1305 union iwreq_data *wrqu, char *extra)
1306{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001307 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 /* Do nothing for now */
1309 return 0;
1310}
1311
1312static int iw_get_name(struct net_device *dev,
1313 struct iw_request_info *info,
1314 char *wrqu, char *extra)
1315{
1316
1317 ENTER();
1318 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1319 EXIT();
1320 return 0;
1321}
1322
1323static int iw_set_mode(struct net_device *dev,
1324 struct iw_request_info *info,
1325 union iwreq_data *wrqu, char *extra)
1326{
1327 hdd_wext_state_t *pWextState;
1328 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1329 tCsrRoamProfile *pRoamProfile;
1330 eCsrRoamBssType LastBSSType;
1331 eMib_dot11DesiredBssType connectedBssType;
1332 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001334
1335 ENTER();
1336
1337 if (NULL == pAdapter)
1338 {
1339 hddLog(VOS_TRACE_LEVEL_WARN,
1340 "%s: Invalid context, pAdapter", __func__);
1341 return 0;
1342 }
1343
1344 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1346 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 return 0;
1348 }
1349
1350 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1351 if (pWextState == NULL)
1352 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301353 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 return -EINVAL;
1355 }
1356
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 pRoamProfile = &pWextState->roamProfile;
1359 LastBSSType = pRoamProfile->BSSType;
1360
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301361 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001362
1363 switch (wrqu->mode)
1364 {
1365 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301366 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1368 // Set the phymode correctly for IBSS.
1369 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1370 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001371 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 break;
1374 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301375 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 break;
1379 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301380 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1382 break;
1383 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301384 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 return -EOPNOTSUPP;
1386 }
1387
1388 if ( LastBSSType != pRoamProfile->BSSType )
1389 {
1390 //the BSS mode changed
1391 // We need to issue disconnect if connected or in IBSS disconnect state
1392 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1393 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1394 {
1395 VOS_STATUS vosStatus;
1396 // need to issue a disconnect to CSR.
1397 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1398 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1399 pAdapter->sessionId,
1400 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1401 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301402 {
1403 long ret;
1404 ret = wait_for_completion_interruptible_timeout(
1405 &pAdapter->disconnect_comp_var,
1406 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1407 if (ret <= 0)
1408 hddLog(VOS_TRACE_LEVEL_ERROR,
1409 FL("failed wait on disconnect_comp_var %ld"), ret);
1410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 }
1412 }
1413
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 EXIT();
1415 return 0;
1416}
1417
1418
1419static int iw_get_mode(struct net_device *dev,
1420 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301421 union iwreq_data *wrqu,
1422 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001423{
1424
1425 hdd_wext_state_t *pWextState;
1426 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1427
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301428 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001429
1430 if (NULL == pAdapter)
1431 {
1432 hddLog(VOS_TRACE_LEVEL_WARN,
1433 "%s: Invalid context, pAdapter", __func__);
1434 return 0;
1435 }
1436
1437 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1439 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 return 0;
1441 }
1442
1443 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1444 if (pWextState == NULL)
1445 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301446 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 return -EINVAL;
1448 }
1449
1450 switch (pWextState->roamProfile.BSSType)
1451 {
1452 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001453 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301454 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 break;
1456 case eCSR_BSS_TYPE_IBSS:
1457 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001458 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301459 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 break;
1461 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001462 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301463 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 break;
1465 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001466 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 break;
1468 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301469
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 return 0;
1471}
1472
1473static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1474 union iwreq_data *wrqu, char *extra)
1475{
1476 v_U32_t numChans = 0;
1477 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1478 v_U32_t indx = 0;
1479 v_U32_t status = 0;
1480
1481 hdd_wext_state_t *pWextState;
1482 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1483 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1484 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1485 tCsrRoamProfile * pRoamProfile;
1486 ENTER();
1487
1488 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1490 return status;
1491 }
1492
1493 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1494
1495 pRoamProfile = &pWextState->roamProfile;
1496
Arif Hussain6d2a3322013-11-17 19:50:10 -08001497 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001498
1499 /* Link is up then return cant set channel*/
1500 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1501 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1502 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001503 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 return -EOPNOTSUPP;
1505 }
1506
1507 /* Settings by Frequency as input */
1508 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1509 (wrqu->freq.m <= (tANI_U32)5.825e8))
1510 {
1511 tANI_U32 freq = wrqu->freq.m / 100000;
1512
1513 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1514 indx++;
1515 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1516 {
1517 return -EINVAL;
1518 }
1519 wrqu->freq.e = 0;
1520 wrqu->freq.m = freq_chan_map[indx].chan;
1521
1522 }
1523
1524 if (wrqu->freq.e == 0)
1525 {
1526 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1527 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1528 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001529 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001530 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1532 return -EINVAL;
1533 }
1534
1535 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1536
1537 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1538 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1540 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 return -EIO;
1542 }
1543
1544 for (indx = 0; indx < numChans; indx++) {
1545 if (wrqu->freq.m == validChan[indx]){
1546 break;
1547 }
1548 }
1549 }
1550 else{
1551
1552 return -EINVAL;
1553 }
1554
1555 if(indx >= numChans)
1556 {
1557 return -EINVAL;
1558 }
1559
1560 /* Set the Operational Channel */
1561 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1562 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1563 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1564
Arif Hussain6d2a3322013-11-17 19:50:10 -08001565 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001566
1567 EXIT();
1568
1569 return status;
1570}
1571
1572static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1573 struct iw_freq *fwrq, char *extra)
1574{
Jeff Johnsone7245742012-09-05 17:12:55 -07001575 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1577 tHalHandle hHal;
1578 hdd_wext_state_t *pWextState;
1579 tCsrRoamProfile * pRoamProfile;
1580 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1581
1582 ENTER();
1583
1584 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1586 return status;
1587 }
1588
1589 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1590 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1591
1592 pRoamProfile = &pWextState->roamProfile;
1593
1594 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1595 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001596 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 {
c_hpothub8245442013-11-20 23:41:09 +05301598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1599 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 return -EIO;
1601 }
1602 else
1603 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001604 status = hdd_wlan_get_freq(channel, &freq);
1605 if( TRUE == status )
1606 {
1607 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1608 * iwlist & iwconfig command shows frequency into proper
1609 * format (2.412 GHz instead of 246.2 MHz)*/
1610 fwrq->m = freq;
1611 fwrq->e = MHZ;
1612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 }
1614 }
1615 else
1616 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001617 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1618 * iwlist & iwconfig command shows frequency into proper
1619 * format (2.412 GHz instead of 246.2 MHz)*/
1620 fwrq->m = 0;
1621 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001623 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001624}
1625
1626static int iw_get_tx_power(struct net_device *dev,
1627 struct iw_request_info *info,
1628 union iwreq_data *wrqu, char *extra)
1629{
1630
1631 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1632 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1633 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1634
1635 if (pHddCtx->isLogpInProgress)
1636 {
1637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1638 "%s:LOGP in Progress. Ignore!!!",__func__);
1639 return -EBUSY;
1640 }
1641
1642 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1643 {
1644 wrqu->txpower.value = 0;
1645 return 0;
1646 }
1647 wlan_hdd_get_classAstats(pAdapter);
1648 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1649
1650 return 0;
1651}
1652
1653static int iw_set_tx_power(struct net_device *dev,
1654 struct iw_request_info *info,
1655 union iwreq_data *wrqu, char *extra)
1656{
1657 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1658 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1659
1660 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1661 {
1662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1663 return 0;
1664 }
1665
1666 ENTER();
1667
1668 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1669 {
c_hpothub8245442013-11-20 23:41:09 +05301670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1671 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 return -EIO;
1673 }
1674
1675 EXIT();
1676
1677 return 0;
1678}
1679
1680static int iw_get_bitrate(struct net_device *dev,
1681 struct iw_request_info *info,
1682 union iwreq_data *wrqu, char *extra)
1683{
1684 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1685 eHalStatus status = eHAL_STATUS_SUCCESS;
1686 hdd_wext_state_t *pWextState;
1687 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1688 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1689
1690 ENTER();
1691
1692 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1694 return status;
1695 }
1696
1697 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1698 wrqu->bitrate.value = 0;
1699 }
1700 else {
1701 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1702 SME_SUMMARY_STATS |
1703 SME_GLOBAL_CLASSA_STATS |
1704 SME_GLOBAL_CLASSB_STATS |
1705 SME_GLOBAL_CLASSC_STATS |
1706 SME_GLOBAL_CLASSD_STATS |
1707 SME_PER_STA_STATS,
1708 hdd_StatisticsCB, 0, FALSE,
1709 pHddStaCtx->conn_info.staId[0], pAdapter );
1710
1711 if(eHAL_STATUS_SUCCESS != status)
1712 {
1713 hddLog(VOS_TRACE_LEVEL_ERROR,
1714 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001715 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 return status;
1717 }
1718
1719 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1720
1721 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1722
1723 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1724 {
1725 hddLog(VOS_TRACE_LEVEL_ERROR,
1726 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001727 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 return VOS_STATUS_E_FAILURE;
1729 }
1730
1731 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1732 }
1733
1734 EXIT();
1735
1736 return vos_status;
1737}
1738/* ccm call back function */
1739
1740static int iw_set_bitrate(struct net_device *dev,
1741 struct iw_request_info *info,
1742 union iwreq_data *wrqu,
1743 char *extra)
1744{
1745 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1746 hdd_wext_state_t *pWextState;
1747 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1748 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1749 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1750 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1751 v_U32_t i, rate;
1752 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1753
1754 ENTER();
1755
1756 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1758 return 0;
1759 }
1760
1761 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1762
1763 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1764 {
1765 return -ENXIO ;
1766 }
1767
1768 rate = wrqu->bitrate.value;
1769
1770 if (rate == -1)
1771 {
1772 rate = WNI_CFG_FIXED_RATE_AUTO;
1773 valid_rate = TRUE;
1774 }
1775 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1776 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1777 {
1778 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1779 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1780 {
1781 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1782 WNI_CFG_SUPPORTED_RATES_11A,
1783 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1784 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1785 WNI_CFG_SUPPORTED_RATES_11B,
1786 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1787 {
1788 for (i = 0; i < (b_len + a_len); ++i)
1789 {
1790 /* supported rates returned is double the actual rate so we divide it by 2 */
1791 if ((supp_rates[i]&0x7F)/2 == rate)
1792 {
1793 valid_rate = TRUE;
1794 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1795 break;
1796 }
1797 }
1798 }
1799 }
1800 }
1801 if (valid_rate != TRUE)
1802 {
1803 return -EINVAL;
1804 }
1805 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1806 WNI_CFG_FIXED_RATE, rate,
1807 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1808 {
c_hpothub8245442013-11-20 23:41:09 +05301809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1810 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 return -EIO;
1812 }
1813 return 0;
1814}
1815
1816
1817static int iw_set_genie(struct net_device *dev,
1818 struct iw_request_info *info,
1819 union iwreq_data *wrqu,
1820 char *extra)
1821{
1822 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1823 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001824 u_int8_t *genie = NULL;
1825 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 v_U16_t remLen;
1827
1828 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001829
1830 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1832 "%s:LOGP in Progress. Ignore!!!", __func__);
1833 return 0;
1834 }
1835
1836 if (!wrqu->data.length) {
1837 hdd_clearRoamProfileIe(pAdapter);
1838 EXIT();
1839 return 0;
1840 }
1841
1842 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1843 wrqu->data.length);
1844 if (NULL == base_genie)
1845 {
1846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1847 "mem_alloc_copy_from_user_helper fail");
1848 return -ENOMEM;
1849 }
1850
1851 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001852
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 remLen = wrqu->data.length;
1854
Arif Hussain6d2a3322013-11-17 19:50:10 -08001855 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001856
1857 /* clear any previous genIE before this call */
1858 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1859
1860 while (remLen >= 2)
1861 {
1862 v_U16_t eLen = 0;
1863 v_U8_t elementId;
1864 elementId = *genie++;
1865 eLen = *genie++;
1866 remLen -= 2;
1867
Arif Hussain6d2a3322013-11-17 19:50:10 -08001868 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 __func__, elementId, eLen);
1870
1871 switch ( elementId )
1872 {
1873 case IE_EID_VENDOR:
1874 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001875 {
1876 kfree(base_genie);
1877 return -EINVAL;
1878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001879
1880 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1881 {
1882 v_U16_t curGenIELen = pWextState->genIE.length;
1883 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1884 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1885
1886 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1887 {
1888 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001889 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001891 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 return -ENOMEM;
1893 }
1894 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1895 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1896 pWextState->genIE.length += eLen + 2;
1897 }
1898 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1899 {
1900 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1901 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1902 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1903 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1904 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1905 }
1906 else /* any vendorId except WPA IE should be accumulated to genIE */
1907 {
1908 v_U16_t curGenIELen = pWextState->genIE.length;
1909 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1910 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1911
1912 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1913 {
1914 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001915 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001917 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 return -ENOMEM;
1919 }
1920 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1921 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1922 pWextState->genIE.length += eLen + 2;
1923 }
1924 break;
1925 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001926 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1928 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1929 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1930 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1931 break;
1932
1933 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001934 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001935 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001936 return 0;
1937 }
1938 genie += eLen;
1939 remLen -= eLen;
1940 }
1941 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001942 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 return 0;
1944}
1945
1946static int iw_get_genie(struct net_device *dev,
1947 struct iw_request_info *info,
1948 union iwreq_data *wrqu,
1949 char *extra)
1950{
1951 hdd_wext_state_t *pWextState;
1952 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1953 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1954 eHalStatus status;
1955 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1956 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1957
1958 ENTER();
1959
1960 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1962 return 0;
1963 }
1964
1965
Arif Hussain6d2a3322013-11-17 19:50:10 -08001966 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001967
1968 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1969
1970 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1971 {
1972 return -ENXIO;
1973 }
1974
1975 // Return something ONLY if we are associated with an RSN or WPA network
1976 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1977 pWextState->roamProfile.negotiatedAuthType))
1978 {
1979 return -ENXIO;
1980 }
1981
1982 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1983 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1984 pAdapter->sessionId,
1985 &length,
1986 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001987 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1988 if (wrqu->data.length < length)
1989 {
1990 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1991 return -EFAULT;
1992 }
Arif Hussain9f05be02014-02-05 12:06:53 -08001993 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08001994 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001995
Arif Hussain6d2a3322013-11-17 19:50:10 -08001996 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001997
1998 EXIT();
1999
2000 return 0;
2001}
2002
2003static int iw_get_encode(struct net_device *dev,
2004 struct iw_request_info *info,
2005 struct iw_point *dwrq, char *extra)
2006{
2007 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2008 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2009 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2010 int keyId;
2011 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2012 int i;
2013
2014 ENTER();
2015
2016 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2018 return 0;
2019 }
2020
2021 keyId = pRoamProfile->Keys.defaultIndex;
2022
2023 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2024 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002025 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 return -EINVAL;
2027 }
2028
2029 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2030 {
2031 dwrq->flags |= IW_ENCODE_ENABLED;
2032 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2033 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2034
2035 dwrq->flags |= (keyId + 1);
2036
2037 }
2038 else
2039 {
2040 dwrq->flags |= IW_ENCODE_DISABLED;
2041 }
2042
2043 for(i=0; i < MAX_WEP_KEYS; i++)
2044 {
2045 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2046 {
2047 continue;
2048 }
2049 else
2050 {
2051 break;
2052 }
2053 }
2054
2055 if(MAX_WEP_KEYS == i)
2056 {
2057 dwrq->flags |= IW_ENCODE_NOKEY;
2058 }
2059
2060 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2061
2062 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2063 {
2064 dwrq->flags |= IW_ENCODE_OPEN;
2065 }
2066 else
2067 {
2068 dwrq->flags |= IW_ENCODE_RESTRICTED;
2069 }
2070 EXIT();
2071 return 0;
2072}
2073
2074#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2075#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2076
2077
2078/*
2079 * This function sends a single 'key' to LIM at all time.
2080 */
2081
2082static int iw_get_rts_threshold(struct net_device *dev,
2083 struct iw_request_info *info,
2084 union iwreq_data *wrqu, char *extra)
2085{
2086 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2087 v_U32_t status = 0;
2088
2089 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2090
2091 return status;
2092}
2093
2094static int iw_set_rts_threshold(struct net_device *dev,
2095 struct iw_request_info *info,
2096 union iwreq_data *wrqu, char *extra)
2097{
2098 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2099 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2100
2101 ENTER();
2102
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002103 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2104 {
2105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2106 "%s:LOGP in Progress. Ignore!!!", __func__);
2107 return -EAGAIN;
2108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2110 {
2111 return -EINVAL;
2112 }
2113
2114 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2115 {
c_hpothub8245442013-11-20 23:41:09 +05302116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2117 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 return -EIO;
2119 }
2120
2121 EXIT();
2122
2123 return 0;
2124}
2125
2126static int iw_get_frag_threshold(struct net_device *dev,
2127 struct iw_request_info *info,
2128 union iwreq_data *wrqu, char *extra)
2129{
2130 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2131 v_U32_t status = 0;
2132
2133 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2134
2135 return status;
2136}
2137
2138static int iw_set_frag_threshold(struct net_device *dev,
2139 struct iw_request_info *info,
2140 union iwreq_data *wrqu, char *extra)
2141{
2142 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2143 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2144
2145 ENTER();
2146
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002147 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2148 {
2149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2150 "%s:LOGP in Progress. Ignore!!!", __func__);
2151 return -EBUSY;
2152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2154 {
2155 return -EINVAL;
2156 }
2157
2158 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2159 {
c_hpothub8245442013-11-20 23:41:09 +05302160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2161 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 return -EIO;
2163 }
2164
2165 EXIT();
2166
2167 return 0;
2168}
2169
2170static int iw_get_power_mode(struct net_device *dev,
2171 struct iw_request_info *info,
2172 union iwreq_data *wrqu, char *extra)
2173{
2174 ENTER();
2175 return -EOPNOTSUPP;
2176}
2177
2178static int iw_set_power_mode(struct net_device *dev,
2179 struct iw_request_info *info,
2180 union iwreq_data *wrqu, char *extra)
2181{
2182 ENTER();
2183 return -EOPNOTSUPP;
2184}
2185
2186static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2187 union iwreq_data *wrqu, char *extra)
2188{
2189 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2190 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2191 struct iw_range *range = (struct iw_range *) extra;
2192
2193 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2194
2195 v_U32_t num_channels = sizeof(channels);
2196 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2197 v_U32_t a_len;
2198 v_U32_t b_len;
2199 v_U32_t active_phy_mode = 0;
2200 v_U8_t index = 0, i;
2201
2202 ENTER();
2203
2204 wrqu->data.length = sizeof(struct iw_range);
2205 memset(range, 0, sizeof(struct iw_range));
2206
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002207 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2208 {
2209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2210 "%s:LOGP in Progress. Ignore!!!", __func__);
2211 return -EBUSY;
2212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002213
2214 /*Get the phy mode*/
2215 if (ccmCfgGetInt(hHal,
2216 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2217 {
2218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002219 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002220
2221 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2222 {
2223 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002224 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 if (ccmCfgGetStr(hHal,
2226 WNI_CFG_SUPPORTED_RATES_11A,
2227 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2228 {
2229 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2230 {
2231 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2232 }
2233 for (i = 0; i < a_len; i++)
2234 {
2235 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2236 }
2237 range->num_bitrates = a_len;
2238 }
2239 else
2240 {
2241 return -EIO;
2242 }
2243 }
2244 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2245 {
2246 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002247 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 if (ccmCfgGetStr(hHal,
2249 WNI_CFG_SUPPORTED_RATES_11B,
2250 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2251 {
2252 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2253 {
2254 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2255 }
2256 for (i = 0; i < b_len; i++)
2257 {
2258 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2259 }
2260 range->num_bitrates = b_len;
2261 }
2262 else
2263 {
2264 return -EIO;
2265 }
2266 }
2267 }
2268
2269 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2270 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2271 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2272
2273 range->encoding_size[0] = 5;
2274 range->encoding_size[1] = 13;
2275 range->num_encoding_sizes = 2;
2276 range->max_encoding_tokens = MAX_WEP_KEYS;
2277
2278 // we support through Wireless Extensions 22
2279 range->we_version_compiled = WIRELESS_EXT;
2280 range->we_version_source = 22;
2281
2282 /*Supported Channels and Frequencies*/
2283 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2284 {
c_hpothub8245442013-11-20 23:41:09 +05302285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2286 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 return -EIO;
2288 }
2289 if (num_channels > IW_MAX_FREQUENCIES)
2290 {
2291 num_channels = IW_MAX_FREQUENCIES;
2292 }
2293
2294 range->num_channels = num_channels;
2295 range->num_frequency = num_channels;
2296
2297 for (index=0; index < num_channels; index++)
2298 {
2299 v_U32_t frq_indx = 0;
2300
2301 range->freq[index].i = channels[index];
2302 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2303 {
2304 if(channels[index] == freq_chan_map[frq_indx].chan)
2305 {
2306 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2307 range->freq[index].e = 1;
2308 break;
2309 }
2310 frq_indx++;
2311 }
2312 }
2313
2314 /* Event capability (kernel + driver) */
2315 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2316 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2317 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2318 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2319
2320 /*Encryption capability*/
2321 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2322 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2323
2324 /* Txpower capability */
2325 range->txpower_capa = IW_TXPOW_MWATT;
2326
2327 /*Scanning capability*/
2328 #if WIRELESS_EXT >= 22
2329 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2330 #endif
2331
2332 EXIT();
2333 return 0;
2334}
2335
2336/* Callback function registered with PMC to know status of PMC request */
2337static void iw_power_callback_fn (void *pContext, eHalStatus status)
2338{
2339 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002340
2341 if (NULL == pContext)
2342 {
2343 hddLog(VOS_TRACE_LEVEL_ERROR,
2344 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002345 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 return;
2347 }
2348
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002350
Jeff Johnson72a40512013-12-19 10:14:15 -08002351 /* there is a race condition that exists between this callback
2352 function and the caller since the caller could time out either
2353 before or while this code is executing. we use a spinlock to
2354 serialize these actions */
2355 spin_lock(&hdd_context_lock);
2356
2357 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 {
2359 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002360 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002362 "%s: Invalid context, magic [%08x]",
2363 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002364
2365 if (ioctl_debug)
2366 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002367 pr_info("%s: Invalid context, magic [%08x]\n",
2368 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 }
2370 return;
2371 }
2372
Jeff Johnson72a40512013-12-19 10:14:15 -08002373 /* context is valid so caller is still waiting */
2374
2375 /* paranoia: invalidate the magic */
2376 pStatsContext->magic = 0;
2377
2378 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002380
2381 /* serialization is complete */
2382 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383}
2384
2385/* Callback function for tx per hit */
2386void hdd_tx_per_hit_cb (void *pCallbackContext)
2387{
2388 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2389 unsigned char tx_fail[16];
2390 union iwreq_data wrqu;
2391
2392 if (NULL == pAdapter)
2393 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002394 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 return;
2396 }
2397 memset(&wrqu, 0, sizeof(wrqu));
2398 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2399 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2400}
2401
2402void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2403{
2404 struct statsContext *pStatsContext;
2405 tCsrGlobalClassAStatsInfo *pClassAStats;
2406 hdd_adapter_t *pAdapter;
2407
2408 if (ioctl_debug)
2409 {
2410 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002411 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 }
2413
2414 if ((NULL == pStats) || (NULL == pContext))
2415 {
2416 hddLog(VOS_TRACE_LEVEL_ERROR,
2417 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002418 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 return;
2420 }
2421
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 pClassAStats = pStats;
2423 pStatsContext = pContext;
2424 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002425
2426 /* there is a race condition that exists between this callback
2427 function and the caller since the caller could time out either
2428 before or while this code is executing. we use a spinlock to
2429 serialize these actions */
2430 spin_lock(&hdd_context_lock);
2431
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2433 {
2434 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002435 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 hddLog(VOS_TRACE_LEVEL_WARN,
2437 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002438 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 if (ioctl_debug)
2440 {
2441 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002442 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 }
2444 return;
2445 }
2446
Jeff Johnson72a40512013-12-19 10:14:15 -08002447 /* context is valid so caller is still waiting */
2448
2449 /* paranoia: invalidate the magic */
2450 pStatsContext->magic = 0;
2451
2452 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2454
Jeff Johnson72a40512013-12-19 10:14:15 -08002455 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002457
2458 /* serialization is complete */
2459 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002460}
2461
2462VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2463{
2464 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2465 eHalStatus hstatus;
2466 long lrc;
2467 struct statsContext context;
2468
2469 if (NULL == pAdapter)
2470 {
2471 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2472 return VOS_STATUS_E_FAULT;
2473 }
2474 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2475 {
2476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2477 return VOS_STATUS_SUCCESS;
2478 }
2479
2480 /* we are connected
2481 prepare our callback context */
2482 init_completion(&context.completion);
2483 context.pAdapter = pAdapter;
2484 context.magic = STATS_CONTEXT_MAGIC;
2485 /* query only for Class A statistics (which include link speed) */
2486 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2487 eCSR_HDD,
2488 SME_GLOBAL_CLASSA_STATS,
2489 hdd_GetClassA_statisticsCB,
2490 0, // not periodic
2491 FALSE, //non-cached results
2492 pHddStaCtx->conn_info.staId[0],
2493 &context);
2494 if (eHAL_STATUS_SUCCESS != hstatus)
2495 {
2496 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002497 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002498 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 /* we'll returned a cached value below */
2500 }
2501 else
2502 {
2503 /* request was sent -- wait for the response */
2504 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2505 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 if (lrc <= 0)
2507 {
2508 hddLog(VOS_TRACE_LEVEL_ERROR,
2509 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002510 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 }
2512 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002513
2514 /* either we never sent a request, we sent a request and received a
2515 response or we sent a request and timed out. if we never sent a
2516 request or if we sent a request and got a response, we want to
2517 clear the magic out of paranoia. if we timed out there is a
2518 race condition such that the callback function could be
2519 executing at the same time we are. of primary concern is if the
2520 callback function had already verified the "magic" but had not
2521 yet set the completion variable when a timeout occurred. we
2522 serialize these activities by invalidating the magic while
2523 holding a shared spinlock which will cause us to block if the
2524 callback is currently executing */
2525 spin_lock(&hdd_context_lock);
2526 context.magic = 0;
2527 spin_unlock(&hdd_context_lock);
2528
2529 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 return VOS_STATUS_SUCCESS;
2531}
2532
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002533static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2534{
2535 struct statsContext *pStatsContext;
2536 tCsrSummaryStatsInfo *pSummaryStats;
2537 tCsrGlobalClassAStatsInfo *pClassAStats;
2538 hdd_adapter_t *pAdapter;
2539
2540 if (ioctl_debug)
2541 {
2542 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002543 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002544 }
2545
2546 if ((NULL == pStats) || (NULL == pContext))
2547 {
2548 hddLog(VOS_TRACE_LEVEL_ERROR,
2549 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002550 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002551 return;
2552 }
2553
Jeff Johnson72a40512013-12-19 10:14:15 -08002554 /* there is a race condition that exists between this callback
2555 function and the caller since the caller could time out either
2556 before or while this code is executing. we use a spinlock to
2557 serialize these actions */
2558 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002559
2560 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2561 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2562 pStatsContext = pContext;
2563 pAdapter = pStatsContext->pAdapter;
2564 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2565 {
2566 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002567 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002568 hddLog(VOS_TRACE_LEVEL_WARN,
2569 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002570 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002571 if (ioctl_debug)
2572 {
2573 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002574 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002575 }
2576 return;
2577 }
2578
Jeff Johnson72a40512013-12-19 10:14:15 -08002579 /* context is valid so caller is still waiting */
2580
2581 /* paranoia: invalidate the magic */
2582 pStatsContext->magic = 0;
2583
2584 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002585 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2586 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2587
Jeff Johnson72a40512013-12-19 10:14:15 -08002588 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002589 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002590
2591 /* serialization is complete */
2592 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002593}
2594
2595VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2596{
2597 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2598 eHalStatus hstatus;
2599 long lrc;
2600 struct statsContext context;
2601
2602 if (NULL == pAdapter)
2603 {
2604 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2605 return VOS_STATUS_SUCCESS;
2606 }
2607
2608 /* we are connected
2609 prepare our callback context */
2610 init_completion(&context.completion);
2611 context.pAdapter = pAdapter;
2612 context.magic = STATS_CONTEXT_MAGIC;
2613
2614 /* query only for Summary & Class A statistics */
2615 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2616 eCSR_HDD,
2617 SME_SUMMARY_STATS |
2618 SME_GLOBAL_CLASSA_STATS,
2619 hdd_get_station_statisticsCB,
2620 0, // not periodic
2621 FALSE, //non-cached results
2622 pHddStaCtx->conn_info.staId[0],
2623 &context);
2624 if (eHAL_STATUS_SUCCESS != hstatus)
2625 {
2626 hddLog(VOS_TRACE_LEVEL_ERROR,
2627 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002628 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002629 /* we'll return with cached values */
2630 }
2631 else
2632 {
2633 /* request was sent -- wait for the response */
2634 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2635 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002636
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002637 if (lrc <= 0)
2638 {
2639 hddLog(VOS_TRACE_LEVEL_ERROR,
2640 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002641 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002642 }
2643 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002644
2645 /* either we never sent a request, we sent a request and received a
2646 response or we sent a request and timed out. if we never sent a
2647 request or if we sent a request and got a response, we want to
2648 clear the magic out of paranoia. if we timed out there is a
2649 race condition such that the callback function could be
2650 executing at the same time we are. of primary concern is if the
2651 callback function had already verified the "magic" but had not
2652 yet set the completion variable when a timeout occurred. we
2653 serialize these activities by invalidating the magic while
2654 holding a shared spinlock which will cause us to block if the
2655 callback is currently executing */
2656 spin_lock(&hdd_context_lock);
2657 context.magic = 0;
2658 spin_unlock(&hdd_context_lock);
2659
2660 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002661 return VOS_STATUS_SUCCESS;
2662}
2663
2664
Jeff Johnson295189b2012-06-20 16:38:30 -07002665/*
2666 * Support for the LINKSPEED private command
2667 * Per the WiFi framework the response must be of the form
2668 * "LinkSpeed xx"
2669 */
2670static int iw_get_linkspeed(struct net_device *dev,
2671 struct iw_request_info *info,
2672 union iwreq_data *wrqu, char *extra)
2673{
2674 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302675 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302677 int len = sizeof(v_U32_t) + 1;
2678 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302680 VOS_STATUS status;
2681 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002682
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302683 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2684
2685 valid = wlan_hdd_validate_context(pHddCtx);
2686
2687 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002688 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302689 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2690 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002691 }
2692
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2694 {
2695 /* we are not connected so we don't have a classAstats */
2696 link_speed = 0;
2697 }
2698 else
2699 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302700 status = wlan_hdd_get_classAstats(pAdapter);
2701
2702 if (!VOS_IS_STATUS_SUCCESS(status ))
2703 {
2704 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2705 return -EINVAL;
2706 }
2707
2708 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2709 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2710 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2711 &link_speed);
2712
2713 link_speed = link_speed / 10;
2714
2715 if (0 == link_speed)
2716 {
2717 /* The linkspeed returned by HAL is in units of 500kbps.
2718 * converting it to mbps.
2719 * This is required to support legacy firmware which does
2720 * not return link capacity.
2721 */
2722 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2723 }
2724
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 }
2726
2727 wrqu->data.length = len;
2728 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002729 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 if ((rc < 0) || (rc >= len))
2731 {
2732 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302733 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 return -EIO;
2735 }
2736
2737 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002738 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002739}
2740
Arif Hussain695279c2014-03-24 14:06:07 -07002741/*
2742 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2743 *
2744 */
2745static int iw_get_linkspeed_priv(struct net_device *dev,
2746 struct iw_request_info *info,
2747 union iwreq_data *wrqu, char *extra)
2748{
2749 int rc;
2750
2751 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2752
2753 if (rc < 0)
2754 return rc;
2755
2756 /* a value is being successfully returned */
2757 return 0;
2758}
Jeff Johnson295189b2012-06-20 16:38:30 -07002759
2760/*
2761 * Support for the RSSI & RSSI-APPROX private commands
2762 * Per the WiFi framework the response must be of the form
2763 * "<ssid> rssi <xx>"
2764 * unless we are not associated, in which case the response is
2765 * "OK"
2766 */
2767static int iw_get_rssi(struct net_device *dev,
2768 struct iw_request_info *info,
2769 union iwreq_data *wrqu, char *extra)
2770{
2771 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002772 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 int len = wrqu->data.length;
2774 v_S7_t s7Rssi = 0;
2775 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2776 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2777 VOS_STATUS vosStatus;
2778 int rc;
2779
2780 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2781 (0 == ssidlen) || (ssidlen >= len))
2782 {
2783 /* we are not connected or our SSID is too long
2784 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002785 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 }
2787 else
2788 {
2789 /* we are connected with a valid SSID
2790 so we can write the SSID into the return buffer
2791 (note that it is not NUL-terminated) */
2792 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2793
2794 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2795
2796 if (VOS_STATUS_SUCCESS == vosStatus)
2797 {
2798 /* append the rssi to the ssid in the format required by
2799 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002800 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302801 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 }
2803 else
2804 {
2805 rc = -1;
2806 }
2807 }
2808
2809 /* verify that we wrote a valid response */
2810 if ((rc < 0) || (rc >= len))
2811 {
2812 // encoding or length error?
2813 hddLog(VOS_TRACE_LEVEL_ERROR,
2814 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002815 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 return -EIO;
2817 }
2818
2819 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002820 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002821}
2822
2823/*
2824 * Support for SoftAP channel range private command
2825 */
2826static int iw_softap_set_channel_range( struct net_device *dev,
2827 int startChannel,
2828 int endChannel,
2829 int band)
2830{
Jeff Johnson43971f52012-07-17 12:26:56 -07002831 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 int ret = 0;
2833 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2834 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002835 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2836
Jeff Johnson295189b2012-06-20 16:38:30 -07002837
2838 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2839 if (VOS_STATUS_SUCCESS != status)
2840 {
2841 ret = -EINVAL;
2842 }
Yathish9f22e662012-12-10 14:21:35 -08002843 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 return ret;
2845}
2846
2847VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2848{
2849 struct statsContext context;
2850 eHalStatus status;
2851 hdd_context_t *pHddCtx;
2852
2853 if (NULL == pAdapter)
2854 {
2855 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2856 return VOS_STATUS_E_FAULT;
2857 }
2858
2859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2860 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05302861 if (pHddCtx->isLogpInProgress) {
2862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2863 "%s:LOGP in Progress. Ignore!!!", __func__);
2864 return VOS_STATUS_E_FAILURE;
2865 }
2866
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 init_completion(&context.completion);
2868
2869 context.pAdapter = pAdapter;
2870 context.magic = POWER_CONTEXT_MAGIC;
2871
2872 if (DRIVER_POWER_MODE_ACTIVE == mode)
2873 {
2874 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2875 "Full Power", __func__);
2876 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2877 iw_power_callback_fn, &context,
2878 eSME_FULL_PWR_NEEDED_BY_HDD);
2879 // Enter Full power command received from GUI this means we are disconnected
2880 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2881 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2882 if (eHAL_STATUS_PMC_PENDING == status)
2883 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002884 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 int lrc = wait_for_completion_interruptible_timeout(
2886 &context.completion,
2887 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002888
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 if (lrc <= 0)
2890 {
2891 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002892 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 }
2894 }
2895 }
2896 else if (DRIVER_POWER_MODE_AUTO == mode)
2897 {
2898 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2899 {
2900 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2901 __func__);
2902 // Enter BMPS command received from GUI this means DHCP is completed
2903 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2904 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2905 FALSE);
2906 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2907 iw_power_callback_fn, &context);
2908 if (eHAL_STATUS_PMC_PENDING == status)
2909 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002910 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 int lrc = wait_for_completion_interruptible_timeout(
2912 &context.completion,
2913 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 if (lrc <= 0)
2915 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002916 hddLog(VOS_TRACE_LEVEL_ERROR,
2917 "%s: SME %s while requesting BMPS",
2918 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 }
2920 }
2921 }
2922 else
2923 {
2924 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2925 "enabled in the cfg");
2926 }
2927 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002928
2929 /* either we never sent a request, we sent a request and received a
2930 response or we sent a request and timed out. if we never sent a
2931 request or if we sent a request and got a response, we want to
2932 clear the magic out of paranoia. if we timed out there is a
2933 race condition such that the callback function could be
2934 executing at the same time we are. of primary concern is if the
2935 callback function had already verified the "magic" but had not
2936 yet set the completion variable when a timeout occurred. we
2937 serialize these activities by invalidating the magic while
2938 holding a shared spinlock which will cause us to block if the
2939 callback is currently executing */
2940 spin_lock(&hdd_context_lock);
2941 context.magic = 0;
2942 spin_unlock(&hdd_context_lock);
2943
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 return VOS_STATUS_SUCCESS;
2945}
2946
2947VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2948 hdd_adapter_t *pAdapter)
2949{
2950 VOS_STATUS vos_Status;
2951
2952 if ((NULL == pAdapter) || (NULL == pHddCtx))
2953 {
2954 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2955 return VOS_STATUS_E_FAULT;
2956 }
2957
2958 /**Exit from Deep sleep or standby if we get the driver
2959 START cmd from android GUI
2960 */
2961 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2962 {
2963 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2964 "from Stand by",__func__);
2965 vos_Status = hdd_exit_standby(pHddCtx);
2966 }
2967 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2968 {
2969 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2970 "from deep sleep",__func__);
2971 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2972 }
2973 else
2974 {
2975 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2976 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2977 vos_Status = VOS_STATUS_SUCCESS;
2978 }
2979
2980 return vos_Status;
2981}
2982
2983VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
2984{
2985 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
2986
2987 if (NULL == pHddCtx)
2988 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302989 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 return VOS_STATUS_E_FAULT;
2991 }
2992
2993 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2994 {
2995 //Execute standby procedure.
2996 //Executing standby procedure will cause the STA to
2997 //disassociate first and then the chip will be put into standby.
2998 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
2999 vos_Status = hdd_enter_standby(pHddCtx);
3000 }
3001 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3002 pHddCtx->cfg_ini->nEnableDriverStop)
3003 {
3004 //Execute deep sleep procedure
3005 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003006 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 //Deep sleep not supported
3008 vos_Status = hdd_enter_standby(pHddCtx);
3009 }
3010 else
3011 {
3012 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3013 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3014 vos_Status = VOS_STATUS_SUCCESS;
3015 }
3016
3017 return vos_Status;
3018}
3019
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003020
3021void* wlan_hdd_change_country_code_callback(void *pAdapter)
3022{
3023
3024 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003025 complete(&call_back_pAdapter->change_country_code);
3026
3027 return NULL;
3028}
3029
Jeff Johnson295189b2012-06-20 16:38:30 -07003030static int iw_set_priv(struct net_device *dev,
3031 struct iw_request_info *info,
3032 union iwreq_data *wrqu, char *extra)
3033{
3034 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003035 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 int cmd_len = wrqu->data.length;
3037 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003038 int rc = 0;
3039 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3040
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3042
3043 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003044 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3045 wrqu->data.length);
3046 if (NULL == cmd)
3047 {
3048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3049 "mem_alloc_copy_from_user_helper fail");
3050 return -ENOMEM;
3051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003052
3053 if (ioctl_debug)
3054 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003055 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 }
3057
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003058 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3059 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003060
3061 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003062 if (ioctl_debug)
3063 {
3064 pr_info("%s: RESTART in progress\n", __func__);
3065 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003066
Arif Hussain24bfa702014-01-22 13:51:30 -08003067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003069 kfree(cmd);
3070 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 }
3072
Arif Hussain24bfa702014-01-22 13:51:30 -08003073 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003075 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3077 "%s: Error in iw_set_scan!", __func__);
3078 rc = -EINVAL;
3079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 }
3081 else if( strcasecmp(cmd, "start") == 0 ) {
3082
Arif Hussain6d2a3322013-11-17 19:50:10 -08003083 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003085
Arif Hussain24bfa702014-01-22 13:51:30 -08003086 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3087 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 {
3089 union iwreq_data wrqu;
3090 char buf[10];
3091
3092 memset(&wrqu, 0, sizeof(wrqu));
3093 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3094 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3095 }
3096 else
3097 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003098 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3099 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 }
3101 goto done;
3102 }
3103 else if( strcasecmp(cmd, "stop") == 0 )
3104 {
3105 union iwreq_data wrqu;
3106 char buf[10];
3107
Arif Hussain6d2a3322013-11-17 19:50:10 -08003108 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003109
3110 wlan_hdd_enter_lowpower(pHddCtx);
3111 memset(&wrqu, 0, sizeof(wrqu));
3112 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3113 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 goto done;
3115 }
3116 else if (strcasecmp(cmd, "macaddr") == 0)
3117 {
3118 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3119 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3120 }
3121 else if (strcasecmp(cmd, "scan-active") == 0)
3122 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303123 hddLog(VOS_TRACE_LEVEL_ERROR,
3124 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003125 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 ret = snprintf(cmd, cmd_len, "OK");
3127 }
3128 else if (strcasecmp(cmd, "scan-passive") == 0)
3129 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303130 hddLog(VOS_TRACE_LEVEL_ERROR,
3131 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003132 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 ret = snprintf(cmd, cmd_len, "OK");
3134 }
3135 else if( strcasecmp(cmd, "scan-mode") == 0 )
3136 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003137 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 }
3139 else if( strcasecmp(cmd, "linkspeed") == 0 )
3140 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003141 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 }
3143 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3144 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003145 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003146 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003147
3148 country_code = cmd + 8;
3149
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003150 init_completion(&pAdapter->change_country_code);
3151
Arif Hussain24bfa702014-01-22 13:51:30 -08003152 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003153 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 country_code,
3155 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303156 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303157 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303158 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003159
3160 /* Wait for completion */
3161 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3162 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3163
3164 if (lrc <= 0)
3165 {
3166 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003167 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003168 }
3169
Arif Hussain24bfa702014-01-22 13:51:30 -08003170 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003172 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003173 "%s: SME Change Country code fail", __func__);
3174 kfree(cmd);
3175 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 }
3177 }
3178 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3179 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003180 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 }
3182 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3183 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003184 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003185
Wilson Yang1be3e652013-10-09 15:18:31 -07003186 if (9 < cmd_len)
3187 {
3188 ptr = (char*)(cmd + 9);
3189
3190 }else{
3191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3192 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003193 kfree(cmd);
3194 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003195 }
3196
3197 if (1 != sscanf(ptr,"%d",&mode))
3198 {
3199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3200 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003201 kfree(cmd);
3202 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003203 }
3204
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 wlan_hdd_enter_bmps(pAdapter, mode);
3206 /*TODO:Set the power mode*/
3207 }
3208 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3209 v_U32_t pmc_state;
3210 v_U16_t value;
3211
3212 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3213 if(pmc_state == BMPS) {
3214 value = DRIVER_POWER_MODE_AUTO;
3215 }
3216 else {
3217 value = DRIVER_POWER_MODE_ACTIVE;
3218 }
3219 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3220 }
3221 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003222 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 /*TODO: set the btcoexmode*/
3224 }
3225 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3226
Arif Hussain6d2a3322013-11-17 19:50:10 -08003227 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 /*TODO: Return the btcoex status*/
3229 }
3230 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3231
Arif Hussain6d2a3322013-11-17 19:50:10 -08003232 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
3234 /*TODO: Enable Rx data Filter*/
3235 }
3236 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3237
Arif Hussain6d2a3322013-11-17 19:50:10 -08003238 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003239
3240 /*TODO: Disable Rx data Filter*/
3241 }
3242 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3243
Arif Hussain6d2a3322013-11-17 19:50:10 -08003244 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 /*TODO: rxfilter-statistics*/
3246 }
3247 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3248
Arif Hussain6d2a3322013-11-17 19:50:10 -08003249 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 /*TODO: rxfilter-add*/
3251 }
3252 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3253
Arif Hussain6d2a3322013-11-17 19:50:10 -08003254 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 /*TODO: rxfilter-remove*/
3256 }
3257#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003258 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3259 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3260 /*TODO: support pnosetup*/
3261 }
3262 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3263 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3264 /*TODO: support pnoforce*/
3265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3267
Arif Hussain6d2a3322013-11-17 19:50:10 -08003268 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003269 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3270 kfree(cmd);
3271 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 }
3273 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003274 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003275 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3276 kfree(cmd);
3277 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 }
3279#endif /*FEATURE_WLAN_SCAN_PNO*/
3280 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003281 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003282 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3283 kfree(cmd);
3284 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 }
3286 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3287 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003288 char *ptr;
3289
3290 if (18 < cmd_len)
3291 {
3292 ptr = (char*)(cmd + 18);
3293 }else{
3294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3295 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003296 kfree(cmd);
3297 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003298 }
3299
Jeff Johnson02797792013-10-26 19:17:13 -07003300 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003301 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3302 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3303 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3304 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3305 {
3306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3307 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003308 kfree(cmd);
3309 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003311
3312 // parameters checking
3313 // period has to be larger than 0
3314 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3315 {
3316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003317 kfree(cmd);
3318 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 }
3320
3321 // use default value 5 is the input is not reasonable. in unit of 10%
3322 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3323 {
3324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3325 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3326 }
3327
3328 // default is 5
3329 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3330 {
3331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3332 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3333 }
3334
Arif Hussain24bfa702014-01-22 13:51:30 -08003335 if (eHAL_STATUS_SUCCESS !=
3336 sme_SetTxPerTracking(pHddCtx->hHal,
3337 hdd_tx_per_hit_cb,
3338 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003340 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 }
3342 }
3343 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003344 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3345 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 }
3347done:
3348 /* many of the commands write information back into the command
3349 string using snprintf(). check the return value here in one
3350 place */
3351 if ((ret < 0) || (ret >= cmd_len))
3352 {
3353 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003354 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003356 else if (ret > 0)
3357 {
3358 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3359 {
3360 hddLog(VOS_TRACE_LEVEL_ERROR,
3361 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003362 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003363 return -EFAULT;
3364 }
3365 wrqu->data.length = ret;
3366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003367
3368 if (ioctl_debug)
3369 {
3370 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003371 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003373 kfree(cmd);
3374 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003375}
3376
3377static int iw_set_nick(struct net_device *dev,
3378 struct iw_request_info *info,
3379 union iwreq_data *wrqu, char *extra)
3380{
3381 ENTER();
3382 return 0;
3383}
3384
3385static int iw_get_nick(struct net_device *dev,
3386 struct iw_request_info *info,
3387 union iwreq_data *wrqu, char *extra)
3388{
3389 ENTER();
3390 return 0;
3391}
3392
3393static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3394{
3395 ENTER();
3396 return NULL;
3397}
3398
3399static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3400 union iwreq_data *wrqu,char *extra)
3401
3402{
3403 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3404 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3405 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3406 struct iw_point *encoderq = &(wrqu->encoding);
3407 v_U32_t keyId;
3408 v_U8_t key_length;
3409 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3410 v_BOOL_t fKeyPresent = 0;
3411 int i;
3412 eHalStatus status = eHAL_STATUS_SUCCESS;
3413
3414
3415 ENTER();
3416
3417 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3418 {
3419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3420 "%s:LOGP in Progress. Ignore!!!",__func__);
3421 return 0;
3422 }
3423
3424
3425 keyId = encoderq->flags & IW_ENCODE_INDEX;
3426
3427 if(keyId)
3428 {
3429 if(keyId > MAX_WEP_KEYS)
3430 {
3431 return -EINVAL;
3432 }
3433
3434 fKeyPresent = 1;
3435 keyId--;
3436 }
3437 else
3438 {
3439 fKeyPresent = 0;
3440 }
3441
3442
3443 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3444 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 if(!fKeyPresent) {
3447
3448 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3449
3450 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3451 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3452 }
3453 }
3454 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3455 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3456 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3457 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3458
3459 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3460 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3461
3462 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3463 {
3464 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3465 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003466 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303467 {
3468 long ret;
3469 ret = wait_for_completion_interruptible_timeout(
3470 &pAdapter->disconnect_comp_var,
3471 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3472 if (ret <= 0)
3473 hddLog(VOS_TRACE_LEVEL_ERROR,
3474 FL("failed wait on disconnect_comp_var %ld"), ret);
3475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 }
3477
3478 return status;
3479
3480 }
3481
3482 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3483 {
3484 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3485
3486 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3487
3488 }
3489
3490
3491 if(wrqu->data.length > 0)
3492 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003493 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003494
3495 key_length = wrqu->data.length;
3496
3497 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3498
3499 if(5 == key_length)
3500 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003501 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003502
3503 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3504 {
3505 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3506 }
3507 else
3508 {
3509 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3510 }
3511 }
3512 else if(13 == key_length)
3513 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003514 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003515
3516 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3517 {
3518 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3519 }
3520 else
3521 {
3522 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3523 }
3524 }
3525 else
3526 {
3527 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003528 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 return -EINVAL;
3530 }
3531
3532 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3533 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3534 pWextState->roamProfile.EncryptionType.numEntries = 1;
3535 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3536 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3537 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3538
3539 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3540 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3541 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3542 {
3543
3544 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3545
3546 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3547 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3548
3549 return status;
3550 }
3551 }
3552
3553 return 0;
3554}
3555
3556static int iw_get_encodeext(struct net_device *dev,
3557 struct iw_request_info *info,
3558 struct iw_point *dwrq,
3559 char *extra)
3560{
3561 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3562 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3563 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3564 int keyId;
3565 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3566 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3567 int i;
3568
3569 ENTER();
3570
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003571 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3572 {
3573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3574 "%s:LOGP in Progress. Ignore!!!", __func__);
3575 return -EBUSY;
3576 }
3577
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 keyId = pRoamProfile->Keys.defaultIndex;
3579
3580 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3581 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003582 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 return -EINVAL;
3584 }
3585
3586 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3587 {
3588 dwrq->flags |= IW_ENCODE_ENABLED;
3589 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303590 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3591 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 }
3593 else
3594 {
3595 dwrq->flags |= IW_ENCODE_DISABLED;
3596 }
3597
3598 for(i=0; i < MAX_WEP_KEYS; i++)
3599 {
3600 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3601 {
3602 continue;
3603 }
3604 else
3605 {
3606 break;
3607 }
3608 }
3609
3610 if(MAX_WEP_KEYS == i)
3611 {
3612 dwrq->flags |= IW_ENCODE_NOKEY;
3613 }
3614 else
3615 {
3616 dwrq->flags |= IW_ENCODE_ENABLED;
3617 }
3618
3619 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3620
3621 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3622 {
3623 dwrq->flags |= IW_ENCODE_DISABLED;
3624 }
3625
3626 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3627
3628 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3629 {
3630 dwrq->flags |= IW_ENCODE_OPEN;
3631 }
3632 else
3633 {
3634 dwrq->flags |= IW_ENCODE_RESTRICTED;
3635 }
3636 EXIT();
3637 return 0;
3638
3639}
3640
3641static int iw_set_encodeext(struct net_device *dev,
3642 struct iw_request_info *info,
3643 union iwreq_data *wrqu, char *extra)
3644{
3645 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3646 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3647 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3648 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3649
3650 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3651 v_U32_t status = 0;
3652
3653 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3654
3655 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3656
3657 int key_index;
3658 struct iw_point *encoding = &wrqu->encoding;
3659 tCsrRoamSetKey setKey;
3660 v_U32_t roamId= 0xFF;
3661 VOS_STATUS vos_status;
3662
3663 ENTER();
3664
3665 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3666 {
3667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3668 "%s:LOGP in Progress. Ignore!!!",__func__);
3669 return 0;
3670 }
3671
3672 key_index = encoding->flags & IW_ENCODE_INDEX;
3673
3674 if(key_index > 0) {
3675
3676 /*Convert from 1-based to 0-based keying*/
3677 key_index--;
3678 }
3679 if(!ext->key_len) {
3680
3681 /*Set the encrytion type to NONE*/
3682 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3683 return status;
3684 }
3685
3686 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3687 (IW_ENCODE_ALG_WEP == ext->alg))
3688 {
3689 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3690
Agarwal Ashish971c2882013-10-30 20:11:12 +05303691 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3692 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 return -EINVAL;
3694 }
3695 else {
3696 /*Static wep, update the roam profile with the keys */
3697 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3698 key_index < CSR_MAX_NUM_KEY) {
3699 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3700 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3701
3702 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3703 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3704
3705 }
3706 }
3707 return status;
3708 }
3709
3710 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3711
3712 setKey.keyId = key_index;
3713 setKey.keyLength = ext->key_len;
3714
3715 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3716 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3717 }
3718
3719 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3720 /*Key direction for group is RX only*/
3721 setKey.keyDirection = eSIR_RX_ONLY;
3722 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3723 }
3724 else {
3725
3726 setKey.keyDirection = eSIR_TX_RX;
3727 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3728 }
3729
3730 /*For supplicant pae role is zero*/
3731 setKey.paeRole = 0;
3732
3733 switch(ext->alg)
3734 {
3735 case IW_ENCODE_ALG_NONE:
3736 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3737 break;
3738
3739 case IW_ENCODE_ALG_WEP:
3740 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3741 break;
3742
3743 case IW_ENCODE_ALG_TKIP:
3744 {
3745 v_U8_t *pKey = &setKey.Key[0];
3746
3747 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3748
3749 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3750
3751 /*Supplicant sends the 32bytes key in this order
3752
3753 |--------------|----------|----------|
3754 | Tk1 |TX-MIC | RX Mic |
3755 |--------------|----------|----------|
3756 <---16bytes---><--8bytes--><--8bytes-->
3757
3758 */
3759 /*Sme expects the 32 bytes key to be in the below order
3760
3761 |--------------|----------|----------|
3762 | Tk1 |RX-MIC | TX Mic |
3763 |--------------|----------|----------|
3764 <---16bytes---><--8bytes--><--8bytes-->
3765 */
3766 /* Copy the Temporal Key 1 (TK1) */
3767 vos_mem_copy(pKey,ext->key,16);
3768
3769 /*Copy the rx mic first*/
3770 vos_mem_copy(&pKey[16],&ext->key[24],8);
3771
3772 /*Copy the tx mic */
3773 vos_mem_copy(&pKey[24],&ext->key[16],8);
3774
3775 }
3776 break;
3777
3778 case IW_ENCODE_ALG_CCMP:
3779 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3780 break;
3781
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003782#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003783#define IW_ENCODE_ALG_KRK 6
3784 case IW_ENCODE_ALG_KRK:
3785 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3786 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003787#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003788
3789 default:
3790 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3791 break;
3792 }
3793
3794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003795 ("%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 -07003796
3797#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303798 /* The supplicant may attempt to set the PTK once pre-authentication
3799 is done. Save the key in the UMAC and include it in the ADD
3800 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303802 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303804 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3805 "%s: Update PreAuth Key success", __func__);
3806 return 0;
3807 }
3808 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3809 {
3810 hddLog(VOS_TRACE_LEVEL_ERROR,
3811 "%s: Update PreAuth Key failed", __func__);
3812 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 }
3814#endif /* WLAN_FEATURE_VOWIFI_11R */
3815
3816 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3817
3818 vos_status = wlan_hdd_check_ula_done(pAdapter);
3819 if ( vos_status != VOS_STATUS_SUCCESS )
3820 {
3821 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3822 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3823 __LINE__, vos_status );
3824
3825 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3826 }
3827
3828 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3829
3830 if ( halStatus != eHAL_STATUS_SUCCESS )
3831 {
3832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3833 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3834 __LINE__, halStatus );
3835
3836 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3837 }
3838
3839 return halStatus;
3840}
3841
3842static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3843 union iwreq_data *wrqu, char *extra)
3844{
3845 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3846 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3847
3848 ENTER();
3849
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003850 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3851 {
3852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3853 "%s:LOGP in Progress. Ignore!!!", __func__);
3854 return -EBUSY;
3855 }
3856
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3858 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3859
Arif Hussain6d2a3322013-11-17 19:50:10 -08003860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003861
3862 return -EINVAL;
3863 }
3864
3865 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3866
3867 if((wrqu->retry.flags & IW_RETRY_LONG))
3868 {
3869 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3870 {
c_hpothub8245442013-11-20 23:41:09 +05303871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3872 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 return -EIO;
3874 }
3875 }
3876 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3877 {
3878 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3879 {
c_hpothub8245442013-11-20 23:41:09 +05303880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3881 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 return -EIO;
3883 }
3884 }
3885 }
3886 else
3887 {
3888 return -EOPNOTSUPP;
3889 }
3890
Arif Hussain6d2a3322013-11-17 19:50:10 -08003891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003892
3893 EXIT();
3894
3895 return 0;
3896
3897}
3898
3899static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3900 union iwreq_data *wrqu, char *extra)
3901{
3902 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3903 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3904 v_U32_t retry = 0;
3905
3906 ENTER();
3907
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003908 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3909 {
3910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3911 "%s:LOGP in Progress. Ignore!!!", __func__);
3912 return -EBUSY;
3913 }
3914
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 if((wrqu->retry.flags & IW_RETRY_LONG))
3916 {
3917 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3918
3919 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3920 {
c_hpothub8245442013-11-20 23:41:09 +05303921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3922 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 return -EIO;
3924 }
3925
3926 wrqu->retry.value = retry;
3927 }
3928 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3929 {
3930 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3931
3932 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3933 {
c_hpothub8245442013-11-20 23:41:09 +05303934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3935 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 return -EIO;
3937 }
3938
3939 wrqu->retry.value = retry;
3940 }
3941 else {
3942 return -EOPNOTSUPP;
3943 }
3944
Arif Hussain6d2a3322013-11-17 19:50:10 -08003945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003946
3947 EXIT();
3948
3949 return 0;
3950}
3951
3952static int iw_set_mlme(struct net_device *dev,
3953 struct iw_request_info *info,
3954 union iwreq_data *wrqu,
3955 char *extra)
3956{
3957 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3958 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3959 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3960 eHalStatus status = eHAL_STATUS_SUCCESS;
3961
3962 ENTER();
3963
3964 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3965 {
3966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3967 "%s:LOGP in Progress. Ignore!!!",__func__);
3968 return 0;
3969 }
3970
3971 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3972 switch (mlme->cmd) {
3973 case IW_MLME_DISASSOC:
3974 case IW_MLME_DEAUTH:
3975
3976 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3977 {
3978 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3979
3980 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3981 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3982
3983 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3984 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
3985
Jeff Johnson43971f52012-07-17 12:26:56 -07003986 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303987 {
3988 long ret;
3989 ret = wait_for_completion_interruptible_timeout(
3990 &pAdapter->disconnect_comp_var,
3991 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3992 if (ret <= 0)
3993 hddLog(VOS_TRACE_LEVEL_ERROR,
3994 FL("failed wait on disconnect_comp_var %ld"), ret);
3995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08003997 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003998 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003999
4000 /* Resetting authKeyMgmt */
4001 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
4002
4003 netif_tx_disable(dev);
4004 netif_carrier_off(dev);
4005
4006 }
4007 else
4008 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004009 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 -07004010 }
4011 break;
4012 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004013 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 return -EINVAL;
4015 }//end of switch
4016
4017 EXIT();
4018
4019 return status;
4020
4021}
4022
4023/* set param sub-ioctls */
4024static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
4025 union iwreq_data *wrqu, char *extra)
4026{
4027 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4028 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4029 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4030 int *value = (int *)extra;
4031 int sub_cmd = value[0];
4032 int set_value = value[1];
4033 int ret = 0; /* success */
4034 int enable_pbm, enable_mp;
4035#ifdef CONFIG_HAS_EARLYSUSPEND
4036 v_U8_t nEnableSuspendOld;
4037#endif
4038 INIT_COMPLETION(pWextState->completion_var);
4039
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004040 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4041 {
4042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4043 "%s:LOGP in Progress. Ignore!!!", __func__);
4044 return -EBUSY;
4045 }
4046
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 switch(sub_cmd)
4048 {
4049 case WE_SET_11D_STATE:
4050 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004051 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004052 memset(&smeConfig, 0x00, sizeof(smeConfig));
4053
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4055
4056 sme_GetConfigParam(hHal,&smeConfig);
4057 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4058
Arif Hussain6d2a3322013-11-17 19:50:10 -08004059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004060
4061 sme_UpdateConfig(hHal,&smeConfig);
4062 }
4063 else {
4064 return -EINVAL;
4065 }
4066 break;
4067 }
4068
4069 case WE_WOWL:
4070 {
4071 switch (set_value)
4072 {
4073 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004074 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 break;
4076 case 0x01:
4077 case 0x02:
4078 case 0x03:
4079 enable_mp = (set_value & 0x01) ? 1 : 0;
4080 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004081 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4083 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4084 break;
4085 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004086 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 ret = -EINVAL;
4088 break;
4089 }
4090
4091 break;
4092 }
4093 case WE_SET_POWER:
4094 {
4095 switch (set_value)
4096 {
4097 case 0: //Full Power
4098 {
4099 struct statsContext context;
4100 eHalStatus status;
4101
4102 init_completion(&context.completion);
4103
4104 context.pAdapter = pAdapter;
4105 context.magic = POWER_CONTEXT_MAGIC;
4106
4107 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4108 iw_power_callback_fn, &context,
4109 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004110 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 {
4112 int lrc = wait_for_completion_interruptible_timeout(
4113 &context.completion,
4114 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004115
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 if (lrc <= 0)
4117 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004118 hddLog(VOS_TRACE_LEVEL_ERROR,
4119 "%s: SME %s while requesting fullpower",
4120 __func__, (0 == lrc) ?
4121 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 }
4123 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004124 /* either we have a response or we timed out. if we timed
4125 out there is a race condition such that the callback
4126 function could be executing at the same time we are. of
4127 primary concern is if the callback function had already
4128 verified the "magic" but had not yet set the completion
4129 variable when a timeout occurred. we serialize these
4130 activities by invalidating the magic while holding a
4131 shared spinlock which will cause us to block if the
4132 callback is currently executing */
4133 spin_lock(&hdd_context_lock);
4134 context.magic = 0;
4135 spin_unlock(&hdd_context_lock);
4136
Arif Hussain6d2a3322013-11-17 19:50:10 -08004137 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 break;
4139 }
4140 case 1: //Enable BMPS
4141 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4142 break;
4143 case 2: //Disable BMPS
4144 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4145 break;
4146 case 3: //Request Bmps
4147 {
4148 struct statsContext context;
4149 eHalStatus status;
4150
4151 init_completion(&context.completion);
4152
4153 context.pAdapter = pAdapter;
4154 context.magic = POWER_CONTEXT_MAGIC;
4155
4156 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4157 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004158 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 {
4160 int lrc = wait_for_completion_interruptible_timeout(
4161 &context.completion,
4162 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 if (lrc <= 0)
4164 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004165 hddLog(VOS_TRACE_LEVEL_ERROR,
4166 "%s: SME %s while requesting BMPS",
4167 __func__, (0 == lrc) ? "timeout" :
4168 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 }
4170 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004171 /* either we have a response or we timed out. if we
4172 timed out there is a race condition such that the
4173 callback function could be executing at the same
4174 time we are. of primary concern is if the callback
4175 function had already verified the "magic" but had
4176 not yet set the completion variable when a timeout
4177 occurred. we serialize these activities by
4178 invalidating the magic while holding a shared
4179 spinlock which will cause us to block if the
4180 callback is currently executing */
4181 spin_lock(&hdd_context_lock);
4182 context.magic = 0;
4183 spin_unlock(&hdd_context_lock);
4184
Arif Hussain6d2a3322013-11-17 19:50:10 -08004185 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 break;
4187 }
4188 case 4: //Enable IMPS
4189 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4190 break;
4191 case 5: //Disable IMPS
4192 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4193 break;
4194 case 6: //Enable Standby
4195 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4196 break;
4197 case 7: //Disable Standby
4198 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4199 break;
4200 case 8: //Request Standby
4201#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004202#endif
4203 break;
4204 case 9: //Start Auto Bmps Timer
4205 sme_StartAutoBmpsTimer(hHal);
4206 break;
4207 case 10://Stop Auto BMPS Timer
4208 sme_StopAutoBmpsTimer(hHal);
4209 break;
4210#ifdef CONFIG_HAS_EARLYSUSPEND
4211 case 11://suspend to standby
4212#ifdef CONFIG_HAS_EARLYSUSPEND
4213 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4214 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4216#endif
4217 break;
4218 case 12://suspend to deep sleep
4219#ifdef CONFIG_HAS_EARLYSUSPEND
4220 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4221 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4223#endif
4224 break;
4225 case 13://resume from suspend
4226#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004227#endif
4228 break;
4229#endif
4230 case 14://reset wlan (power down/power up)
4231 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4232 break;
4233 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004234 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 ret = -EINVAL;
4236 break;
4237 }
4238 break;
4239 }
4240
4241 case WE_SET_MAX_ASSOC:
4242 {
4243 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4244 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4245 {
4246 ret = -EINVAL;
4247 }
4248 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4249 set_value, NULL, eANI_BOOLEAN_FALSE)
4250 != eHAL_STATUS_SUCCESS )
4251 {
c_hpothub8245442013-11-20 23:41:09 +05304252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4253 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 ret = -EIO;
4255 }
4256 break;
4257 }
4258
4259 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4260 {
4261 if( 0 == set_value )
4262 {
4263 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4264 }
4265 else if ( 1 == set_value )
4266 {
4267 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4268 }
4269 else
4270 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004271 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 ret = -EINVAL;
4273 }
4274 break;
4275 }
4276
4277 case WE_SET_DATA_INACTIVITY_TO:
4278 {
4279 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4280 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4281 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4282 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4283 set_value,
4284 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4285 {
4286 hddLog(LOGE,"Failure: Could not pass on "
4287 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004288 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 ret = -EINVAL;
4290 }
4291 break;
4292 }
4293 case WE_SET_MAX_TX_POWER:
4294 {
4295 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4296 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4297
4298 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4299 __func__, set_value);
4300 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4301 eHAL_STATUS_SUCCESS )
4302 {
4303 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4304 __func__);
4305 return -EIO;
4306 }
4307
4308 break;
4309 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004310 case WE_SET_MAX_TX_POWER_2_4:
4311 {
4312 hddLog(VOS_TRACE_LEVEL_INFO,
4313 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4314 __func__, set_value);
4315 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4316 eHAL_STATUS_SUCCESS)
4317 {
4318 hddLog(VOS_TRACE_LEVEL_ERROR,
4319 "%s: Setting maximum tx power failed for 2.4 GHz band",
4320 __func__);
4321 return -EIO;
4322 }
4323
4324 break;
4325 }
4326 case WE_SET_MAX_TX_POWER_5_0:
4327 {
4328 hddLog(VOS_TRACE_LEVEL_INFO,
4329 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4330 __func__, set_value);
4331 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4332 eHAL_STATUS_SUCCESS)
4333 {
4334 hddLog(VOS_TRACE_LEVEL_ERROR,
4335 "%s: Setting maximum tx power failed for 5.0 GHz band",
4336 __func__);
4337 return -EIO;
4338 }
4339
4340 break;
4341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 case WE_SET_HIGHER_DTIM_TRANSITION:
4343 {
4344 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4345 (set_value == eANI_BOOLEAN_TRUE)))
4346 {
4347 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4348 ret = -EINVAL;
4349 }
4350 else
4351 {
4352 if(pAdapter->higherDtimTransition != set_value)
4353 {
4354 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004355 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 }
4357 }
4358
4359 break;
4360 }
4361
4362 case WE_SET_TM_LEVEL:
4363 {
4364 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004365 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4367
4368 break;
4369 }
4370
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304371 case WE_ENABLE_STRICT_FCC_REG:
4372 {
4373 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4374 struct wiphy *wiphy = NULL;
4375 long lrc;
4376 int status;
4377
4378 wiphy = hddCtxt->wiphy;
4379 if(wiphy == NULL)
4380 {
4381 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4382 break;
4383 }
4384 init_completion(&hddCtxt->wiphy_channel_update_event);
4385
4386 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4387
4388 status = regulatory_hint(wiphy, "00");
4389 if(status < 0)
4390 {
4391 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4392 break;
4393 }
4394
4395 /* Wait for completion */
4396 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4397 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4398 if (lrc <= 0)
4399 {
4400 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4401 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4402 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4403 }
4404 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4405
4406 break;
4407 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004408 case WE_SET_DEBUG_LOG:
4409 {
4410 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4411 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4412 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4413 break;
4414 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304415
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 default:
4417 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004418 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 sub_cmd, set_value);
4420 break;
4421 }
4422 }
4423
4424 return ret;
4425}
4426
4427/* set param sub-ioctls */
4428static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4429 union iwreq_data *wrqu, char *extra)
4430{
4431 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05304432 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004434 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4436 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4437#ifdef WLAN_FEATURE_VOWIFI
4438 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4439#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05304440 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07004441
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004442 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4443 {
4444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4445 "%s:LOGP in Progress. Ignore!!!", __func__);
4446 return -EBUSY;
4447 }
4448
Girish Gowli552fc072014-06-14 18:26:16 +05304449 /* helper function to get iwreq_data with compat handling. */
4450 if (hdd_priv_get_data(&s_priv_data, wrqu))
4451 {
4452 return -EINVAL;
4453 }
4454
4455 /* make sure all params are correctly passed to function */
4456 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
4457 {
4458 return -EINVAL;
4459 }
4460
4461 sub_cmd = s_priv_data.flags;
4462
Arif Hussain0273cba2014-01-07 20:58:29 -08004463 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05304464 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
4465 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004466 if (NULL == pBuffer)
4467 {
4468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4469 "mem_alloc_copy_from_user_helper fail");
4470 return -ENOMEM;
4471 }
4472
4473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05304474 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4476 "%s: Received data %s", __func__, pBuffer);
4477
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 switch(sub_cmd)
4479 {
4480 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004482 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 break;
4484 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004486 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 break;
4488#if defined WLAN_FEATURE_VOWIFI
4489 case WE_NEIGHBOR_REPORT_REQUEST:
4490 {
4491 tRrmNeighborReq neighborReq;
4492 tRrmNeighborRspCallbackInfo callbackInfo;
4493
4494 if (pConfig->fRrmEnable)
4495 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05304497 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 if( !neighborReq.no_ssid )
4499 {
Girish Gowli552fc072014-06-14 18:26:16 +05304500 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004501 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 }
4503
4504 callbackInfo.neighborRspCallback = NULL;
4505 callbackInfo.neighborRspCallbackContext = NULL;
4506 callbackInfo.timeout = 5000; //5 seconds
4507 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4508 }
4509 else
4510 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004511 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 ret = -EINVAL;
4513 }
4514 }
4515 break;
4516#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 case WE_SET_AP_WPS_IE:
4518 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05304519 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004522 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 if (VOS_STATUS_SUCCESS != vstatus)
4524 {
4525 ret = -EINVAL;
4526 }
4527 break;
4528 default:
4529 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004530 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 ret = -EINVAL;
4532 break;
4533 }
4534 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004535 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 return ret;
4537}
4538
4539/* get param sub-ioctls */
4540static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4541 union iwreq_data *wrqu, char *extra)
4542{
4543 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4544 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4545 int *value = (int *)extra;
4546 int ret = 0; /* success */
4547
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004548 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4549 {
4550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4551 "%s:LOGP in Progress. Ignore!!!", __func__);
4552 return -EBUSY;
4553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004554
4555 switch (value[0])
4556 {
4557 case WE_GET_11D_STATE:
4558 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004559 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304561
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4563
Arif Hussain6d2a3322013-11-17 19:50:10 -08004564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004565
4566 break;
4567 }
4568
4569 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 break;
4572
4573 case WE_PMC_STATE:
4574 {
4575 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 break;
4578 }
4579 case WE_GET_WLAN_DBG:
4580 {
4581 vos_trace_display();
4582 *value = 0;
4583 break;
4584 }
4585 case WE_MODULE_DOWN_IND:
4586 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
4589#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4592#endif
4593 //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
4594
4595 *value = 0;
4596 break;
4597 }
4598 case WE_GET_MAX_ASSOC:
4599 {
4600 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4601 {
c_hpothub8245442013-11-20 23:41:09 +05304602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4603 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 ret = -EIO;
4605 }
4606 break;
4607 }
4608
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 case WE_GET_WDI_DBG:
4610 {
4611 wpalTraceDisplay();
4612 *value = 0;
4613 break;
4614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004615
4616 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4617 {
4618 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4619 break;
4620 }
4621 case WE_GET_CONCURRENCY_MODE:
4622 {
4623 *value = hdd_get_concurrency_mode ( );
4624
Arif Hussain6d2a3322013-11-17 19:50:10 -08004625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 break;
4627 }
4628
4629 default:
4630 {
4631 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4632 break;
4633 }
4634 }
4635
4636 return ret;
4637}
4638
4639/* set param sub-ioctls */
4640int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4641 union iwreq_data *wrqu, char *extra)
4642{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004643 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 int *value = (int *)extra;
4645 int sub_cmd = value[0];
4646 int ret = 0;
4647
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004648 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4649 {
4650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4651 "%s:LOGP in Progress. Ignore!!!", __func__);
4652 return -EBUSY;
4653 }
4654
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 switch(sub_cmd)
4656 {
4657 case WE_SET_WLAN_DBG:
4658 {
4659 vos_trace_setValue( value[1], value[2], value[3]);
4660 break;
4661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 case WE_SET_WDI_DBG:
4663 {
4664 wpalTraceSetLevel( value[1], value[2], value[3]);
4665 break;
4666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 case WE_SET_SAP_CHANNELS:
4668 {
4669 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4670 break;
4671 }
4672
4673 default:
4674 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004675 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 break;
4677 }
4678 }
4679 return ret;
4680}
4681
4682static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4683 union iwreq_data *wrqu, char *extra)
4684{
4685 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4686 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004687#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004688 hdd_wext_state_t *pWextState;
4689#endif
4690
4691 if (pAdapter == NULL)
4692 {
4693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4694 "%s: pAdapter is NULL!", __func__);
4695 return -EINVAL;
4696 }
4697#ifdef WLAN_FEATURE_11W
4698 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004699#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004700
Yue Ma3ede6052013-08-29 00:33:26 -07004701 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4702 {
4703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4704 "%s: HDD Context is NULL!", __func__);
4705
4706 return -EINVAL;
4707 }
4708
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004709 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4710 {
4711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4712 "%s:LOGP in Progress. Ignore!!!", __func__);
4713 return -EBUSY;
4714 }
4715
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 switch(sub_cmd)
4717 {
4718 case WE_WLAN_VERSION:
4719 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004720 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 break;
4722 }
4723
4724 case WE_GET_STATS:
4725 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304726 tHalHandle hHal = NULL;
4727 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4729 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4730 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4731
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304732
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 snprintf(extra, WE_MAX_STR_LEN,
4734 "\nTransmit"
4735 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4736 "\n dropped BK %u, BE %u, VI %u, VO %u"
4737 "\n classified BK %u, BE %u, VI %u, VO %u"
4738 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4739 "\n queued BK %u, BE %u, VI %u, VO %u"
4740 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004741 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 "\n fetched BK %u, BE %u, VI %u, VO %u"
4743 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4744 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004745 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 "\n flushed BK %u, BE %u, VI %u, VO %u"
4747 "\n\nReceive"
4748 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4749 "\n\nResetsStats"
4750 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4751 "\n",
4752 pStats->txXmitCalled,
4753 pStats->txXmitDropped,
4754 pStats->txXmitBackPressured,
4755 pStats->txXmitQueued,
4756
4757 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4758 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4759 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4760 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4761
4762 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4763 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4764 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4765 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4766
4767 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4768 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4769 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4770 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4771
4772 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4773 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4774 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4775 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4776
4777 pStats->txFetched,
4778 pStats->txFetchEmpty,
4779 pStats->txFetchLowResources,
4780 pStats->txFetchDequeueError,
4781
4782 pStats->txFetchDequeued,
4783 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004784 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 pStats->txCompleted,
4786 pStats->txFlushed,
4787
4788 pStats->txFetchedAC[WLANTL_AC_BK],
4789 pStats->txFetchedAC[WLANTL_AC_BE],
4790 pStats->txFetchedAC[WLANTL_AC_VI],
4791 pStats->txFetchedAC[WLANTL_AC_VO],
4792
4793 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4794 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4795 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4796 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4797
4798 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4799 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4800 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4801 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4802
Ravi Joshi41914632013-10-21 23:02:21 -07004803 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4804 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4805 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4806 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4807
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 pStats->txFlushedAC[WLANTL_AC_BK],
4809 pStats->txFlushedAC[WLANTL_AC_BE],
4810 pStats->txFlushedAC[WLANTL_AC_VI],
4811 pStats->txFlushedAC[WLANTL_AC_VO],
4812
4813 pStats->rxChains,
4814 pStats->rxPackets,
4815 pStats->rxDropped,
4816 pStats->rxDelivered,
4817 pStats->rxRefused,
4818
4819 pResetStats->totalLogpResets,
4820 pResetStats->totalCMD53Failures,
4821 pResetStats->totalMutexReadFailures,
4822 pResetStats->totalMIFErrorFailures,
4823 pResetStats->totalFWHearbeatFailures,
4824 pResetStats->totalUnknownExceptions
4825 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304826 wrqu->data.length = strlen(extra);
4827
4828 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
4829
4830 if (hHal)
4831 pMac = PMAC_STRUCT( hHal );
4832
4833 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
4834 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
4835 snprintf(extra+wrqu->data.length, pmmStatsLength,
4836 "\n BMPS sleepcnt %llx, BMPS awakecnt %llx"
4837 "\n BMPS sleepreqfailcnt %llx, BMPS wakeupreqfailcnt %llx"
4838 "\n IMPS sleepcnt %llx, IMPS awakecnt %llx"
4839 "\n IMPS sleeperrcnt %llx, IMPS wakeuperrcnt %llx, IMPS lasterr %llx"
4840 "\n",
4841 pMac->pmm.BmpscntSleep,
4842 pMac->pmm.BmpscntAwake,
4843 pMac->pmm.BmpsSleeReqFailCnt,
4844 pMac->pmm.BmpsWakeupReqFailCnt,
4845 pMac->pmm.ImpsCntSleep,
4846 pMac->pmm.ImpsCntAwake,
4847 pMac->pmm.ImpsSleepErrCnt,
4848 pMac->pmm.ImpsWakeupErrCnt,
4849 pMac->pmm.ImpsLastErr
4850 );
4851 }
4852
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 wrqu->data.length = strlen(extra)+1;
4854 break;
4855 }
4856
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304857/* The case prints the current state of the HDD, SME, CSR, PE, TL
4858 *it can be extended for WDI Global State as well.
4859 *And currently it only checks P2P_CLIENT adapter.
4860 *P2P_DEVICE and P2P_GO have not been added as of now.
4861*/
4862 case WE_GET_STATES:
4863 {
4864 int buf = 0, len = 0;
4865 int adapter_num = 0;
4866 int count = 0, check = 1;
4867
4868 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004869 tHalHandle hHal = NULL;
4870 tpAniSirGlobal pMac = NULL;
4871 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304872
4873 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4874 hdd_adapter_t *useAdapter = NULL;
4875
4876 /* Print wlan0 or p2p0 states based on the adapter_num
4877 *by using the correct adapter
4878 */
4879 while ( adapter_num < 2 )
4880 {
4881 if ( WLAN_ADAPTER == adapter_num )
4882 {
4883 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004884 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304885 "\n\n wlan0 States:-");
4886 len += buf;
4887 }
4888 else if ( P2P_ADAPTER == adapter_num )
4889 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004890 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304891 "\n\n p2p0 States:-");
4892 len += buf;
4893
4894 if( !pHddCtx )
4895 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004896 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304897 "\n pHddCtx is NULL");
4898 len += buf;
4899 break;
4900 }
4901
4902 /*Printing p2p0 states only in the case when the device is
4903 configured as a p2p_client*/
4904 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4905 if ( !useAdapter )
4906 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004907 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304908 "\n Device not configured as P2P_CLIENT.");
4909 len += buf;
4910 break;
4911 }
4912 }
4913
4914 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004915 if (!hHal) {
4916 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4917 "\n pMac is NULL");
4918 len += buf;
4919 break;
4920 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304921 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004922 if (!pMac) {
4923 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4924 "\n pMac is NULL");
4925 len += buf;
4926 break;
4927 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304928 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4929 if( !pHddStaCtx )
4930 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004931 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304932 "\n pHddStaCtx is NULL");
4933 len += buf;
4934 break;
4935 }
4936
4937 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4938
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004939 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304940 "\n HDD Conn State - %s "
4941 "\n \n SME State:"
4942 "\n Neighbour Roam State - %s"
4943 "\n CSR State - %s"
4944 "\n CSR Substate - %s"
4945 "\n \n TL STA %d State: %s",
4946 macTraceGetHDDWlanConnState(
4947 pHddStaCtx->conn_info.connState),
4948 macTraceGetNeighbourRoamState(
4949 pMac->roam.neighborRoamInfo.neighborRoamState),
4950 macTraceGetcsrRoamState(
4951 pMac->roam.curState[useAdapter->sessionId]),
4952 macTraceGetcsrRoamSubState(
4953 pMac->roam.curSubState[useAdapter->sessionId]),
4954 pHddStaCtx->conn_info.staId[0],
4955 macTraceGetTLState(tlState)
4956 );
4957 len += buf;
4958 adapter_num++;
4959 }
4960
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004961 if (pMac) {
4962 /* Printing Lim State starting with global lim states */
4963 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4964 "\n \n LIM STATES:-"
4965 "\n Global Sme State - %s "\
4966 "\n Global mlm State - %s "\
4967 "\n",
4968 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
4969 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
4970 );
4971 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304972
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004973 /*printing the PE Sme and Mlm states for valid lim sessions*/
4974 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304975 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004976 if ( pMac->lim.gpSession[count].valid )
4977 {
4978 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4979 "\n Lim Valid Session %d:-"
4980 "\n PE Sme State - %s "
4981 "\n PE Mlm State - %s "
4982 "\n",
4983 check,
4984 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
4985 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
4986 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304987
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004988 len += buf;
4989 check++;
4990 }
4991 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304992 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304993 }
4994
4995 wrqu->data.length = strlen(extra)+1;
4996 break;
4997 }
4998
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 case WE_GET_CFG:
5000 {
5001 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
5002 wrqu->data.length = strlen(extra)+1;
5003 break;
5004 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005005#ifdef WLAN_FEATURE_11AC
5006 case WE_GET_RSSI:
5007 {
5008 v_S7_t s7Rssi = 0;
5009 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
5010 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
5011 wrqu->data.length = strlen(extra)+1;
5012 break;
5013 }
5014#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305015
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005016#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005017 case WE_GET_ROAM_RSSI:
5018 {
5019 v_S7_t s7Rssi = 0;
5020 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
5021 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
5022 wrqu->data.length = strlen(extra)+1;
5023 break;
5024 }
5025#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 case WE_GET_WMM_STATUS:
5027 {
5028 snprintf(extra, WE_MAX_STR_LEN,
5029 "\nDir: 0=up, 1=down, 3=both\n"
5030 "|------------------------|\n"
5031 "|AC | ACM |Admitted| Dir |\n"
5032 "|------------------------|\n"
5033 "|VO | %d | %3s | %d |\n"
5034 "|VI | %d | %3s | %d |\n"
5035 "|BE | %d | %3s | %d |\n"
5036 "|BK | %d | %3s | %d |\n"
5037 "|------------------------|\n",
5038 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
5039 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
5040 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
5041 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
5042 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
5043 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
5044 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
5045 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
5046 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5047 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5048 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5049 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5050
Jeff Johnsone7245742012-09-05 17:12:55 -07005051
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 wrqu->data.length = strlen(extra)+1;
5053 break;
5054 }
5055 case WE_GET_CHANNEL_LIST:
5056 {
5057 VOS_STATUS status;
5058 v_U8_t i, len;
5059 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305060 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5061 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5062 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 tChannelListInfo channel_list;
5064
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005065 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005067 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005069 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 return -EINVAL;
5071 }
5072 buf = extra;
5073
5074 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005075 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5076 * needed = 5 * number of channels. Check ifsufficient
5077 * buffer is available and then proceed to fill the buffer.
5078 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5080 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005081 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005082 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005083 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 return -EINVAL;
5085 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005086 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5087 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305088 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5089 {
5090 //Printing Country code in getChannelList
5091 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5092 {
5093 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5094 "%c ", pBuf[i]);
5095 }
5096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 for(i = 0 ; i < channel_list.num_channels; i++)
5098 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005099 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 }
5102 wrqu->data.length = strlen(extra)+1;
5103
5104 break;
5105 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005106#ifdef FEATURE_WLAN_TDLS
5107 case WE_GET_TDLS_PEERS:
5108 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005109 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005110 break;
5111 }
5112#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005113#ifdef WLAN_FEATURE_11W
5114 case WE_GET_11W_INFO:
5115 {
5116 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5117
5118 snprintf(extra, WE_MAX_STR_LEN,
5119 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5120 "\n Number of Unprotected Disassocs %d"
5121 "\n Number of Unprotected Deauths %d",
5122 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5123 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5124 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5125 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5126 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5127
5128 wrqu->data.length = strlen(extra)+1;
5129 break;
5130 }
5131#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305132 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005134 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 break;
5136 }
5137 }
5138
5139 return 0;
5140}
5141
5142/* action sub-ioctls */
5143static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5144 union iwreq_data *wrqu, char *extra)
5145{
5146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305147 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005148 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305149 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005150
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005151 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5152 {
5153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5154 "%s:LOGP in Progress. Ignore!!!", __func__);
5155 return -EBUSY;
5156 }
5157
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305158 /* helper function to get iwreq_data with compat handling. */
5159 if (hdd_priv_get_data(&s_priv_data, wrqu))
5160 {
5161 return -EINVAL;
5162 }
5163
5164 sub_cmd = s_priv_data.flags;
5165
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 switch (sub_cmd)
5167 {
5168 case WE_CLEAR_STATS:
5169 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5172 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5173 break;
5174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005175 case WE_INIT_AP:
5176 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305177 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5178
5179 /* As Soft AP mode might been changed to STA already with
5180 * killing of Hostapd, need to find the adpater by name
5181 * rather than mode */
5182 hdd_adapter_t* pAdapter_to_stop =
5183 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5184 if( pAdapter_to_stop )
5185 {
5186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5187 "Adapter with name softap.0 already "
5188 "exist, ignoring the request.\nRemove the "
5189 "adapter and try again\n");
5190 break;
5191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 pr_info("Init AP trigger\n");
5193 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5194 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5195 break;
5196 }
5197 case WE_STOP_AP:
5198 {
5199 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5200 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5201 * this is a dead code and need to find the adpater by name rather than mode */
5202 hdd_adapter_t* pAdapter_to_stop =
5203 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5204 if( pAdapter_to_stop )
5205 {
5206 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5207
5208 pr_info("Stopping AP mode\n");
5209
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305210 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5211 {
5212 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5213 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5214 }
5215
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305217 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5219 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5220
5221 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5222 pAdapter_to_stop->macAddressCurrent.bytes);
5223 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5224 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305225
5226 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5227 {
5228 /* put the device back into BMPS */
5229 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 }
5232 else
5233 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005234 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 }
5236
5237 break;
5238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005239#ifdef WLAN_BTAMP_FEATURE
5240 case WE_ENABLE_AMP:
5241 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 WLANBAP_RegisterWithHCI(pAdapter);
5244 break;
5245 }
5246 case WE_DISABLE_AMP:
5247 {
5248 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5249 VOS_STATUS status;
5250
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005252
5253 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5254 status = WLANBAP_StopAmp();
5255 if(VOS_STATUS_SUCCESS != status )
5256 {
5257 pHddCtx->isAmpAllowed = VOS_TRUE;
5258 hddLog(VOS_TRACE_LEVEL_FATAL,
5259 "%s: Failed to stop AMP", __func__);
5260 }
5261 else
5262 {
5263 //a state m/c implementation in PAL is TBD to avoid this delay
5264 msleep(500);
5265 pHddCtx->isAmpAllowed = VOS_FALSE;
5266 WLANBAP_DeregisterFromHCI();
5267 }
5268
5269 break;
5270 }
5271#endif
5272
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005273 case WE_ENABLE_DXE_STALL_DETECT:
5274 {
schang6295e542013-03-12 15:31:23 -07005275 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5276 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005277 break;
5278 }
5279 case WE_DISPLAY_DXE_SNAP_SHOT:
5280 {
schang6295e542013-03-12 15:31:23 -07005281 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5282 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005283 break;
5284 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305285 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5286 {
5287 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5288 hdd_wmm_tx_snapshot(pAdapter);
5289 WLANTL_TLDebugMessage(VOS_TRUE);
5290 break;
5291 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305292
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305293 case WE_SET_REASSOC_TRIGGER:
5294 {
5295 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5296 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5297 v_U32_t roamId = 0;
5298 tCsrRoamModifyProfileFields modProfileFields;
5299 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5300 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5301 return 0;
5302 }
5303
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305304 case WE_STOP_OBSS_SCAN:
5305 {
5306 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5307 2.OBSS scan is stopped by Firmware during the disassociation
5308 3.OBSS stop comamnd is added for debugging purpose*/
5309 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5310 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005311
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305312 if (pAdapter == NULL)
5313 {
5314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5315 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305316 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305317 }
5318 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5319 if (pMac == NULL)
5320 {
5321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5322 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305323 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305324 }
5325 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5326 }
5327 break;
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305328
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 default:
5330 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005331 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 break;
5333 }
5334 }
5335
5336 return ret;
5337}
5338
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305339void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5340{
5341 /*
5342 * Function to display HDD WMM information
5343 * for Tx Queues.
5344 * Prints globala as well as per client depending
5345 * whether the clients are registered or not.
5346 */
5347 int i = 0, j = 0;
5348 for ( i=0; i< NUM_TX_QUEUES; i++)
5349 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305350 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005351 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305352 i, pAdapter->wmm_tx_queue[i].count,
5353 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305354 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305355 }
5356
5357 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5358 {
5359 if(pAdapter->aStaInfo[i].isUsed)
5360 {
5361 hddLog(LOGE, "******STAIndex: %d*********", i);
5362 for ( j=0; j< NUM_TX_QUEUES; j++)
5363 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305364 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005365 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305366 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5367 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5368 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305369 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305370 }
5371 }
5372 }
5373
5374}
Jeff Johnson295189b2012-06-20 16:38:30 -07005375int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5376 union iwreq_data *wrqu, char *extra)
5377{
5378 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5379 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05305380 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 int apps_args[MAX_VAR_ARGS] = {0};
Girish Gowlid4522fd2014-06-14 17:20:27 +05305382 int num_args;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005383 hdd_station_ctx_t *pStaCtx = NULL ;
5384 hdd_ap_ctx_t *pAPCtx = NULL;
5385 int cmd = 0;
5386 int staId = 0;
Girish Gowlid4522fd2014-06-14 17:20:27 +05305387 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005388
Girish Gowlid4522fd2014-06-14 17:20:27 +05305389 /* helper function to get iwreq_data with compat handling. */
5390 if (hdd_priv_get_data(&s_priv_data, wrqu))
5391 {
5392 return -EINVAL;
5393 }
5394
5395 if (NULL == s_priv_data.pointer)
5396 {
5397 return -EINVAL;
5398 }
5399
5400 sub_cmd = s_priv_data.flags;
5401 num_args = s_priv_data.length;
5402
5403 hddLog(LOG1, "%s: Received length %d", __func__, s_priv_data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005404
5405 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5406 {
5407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5408 "%s:LOGP in Progress. Ignore!!!", __func__);
5409 return -EBUSY;
5410 }
5411
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 if (num_args > MAX_VAR_ARGS)
5413 {
5414 num_args = MAX_VAR_ARGS;
5415 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005416
5417 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlid4522fd2014-06-14 17:20:27 +05305418 if (copy_from_user(apps_args, s_priv_data.pointer, (sizeof(int)) * num_args))
Arif Hussain0273cba2014-01-07 20:58:29 -08005419 {
5420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5421 "%s: failed to copy data to user buffer", __func__);
5422 return -EFAULT;
5423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005424
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005425 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5426 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5427 {
5428 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5429 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5430 {
5431 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5432 staId = pStaCtx->conn_info.staId[0];
5433 }
5434 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5435 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5436 {
5437 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5438 staId = pAPCtx->uBCStaId;
5439 }
5440 else
5441 {
5442 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5443 return 0;
5444 }
5445 }
5446
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 switch (sub_cmd)
5448 {
5449 case WE_LOG_DUMP_CMD:
5450 {
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305451 vos_ssr_protect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005453 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 apps_args[3], apps_args[4]);
5455
5456 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5457 apps_args[3], apps_args[4]);
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305458 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005459
5460 }
5461 break;
5462
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 case WE_P2P_NOA_CMD:
5464 {
5465 p2p_app_setP2pPs_t p2pNoA;
5466
5467 p2pNoA.opp_ps = apps_args[0];
5468 p2pNoA.ctWindow = apps_args[1];
5469 p2pNoA.duration = apps_args[2];
5470 p2pNoA.interval = apps_args[3];
5471 p2pNoA.count = apps_args[4];
5472 p2pNoA.single_noa_duration = apps_args[5];
5473 p2pNoA.psSelection = apps_args[6];
5474
5475 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5476 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005477 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5479
5480 hdd_setP2pPs(dev, &p2pNoA);
5481
5482 }
5483 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005484
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305485 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5486 {
5487 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5488 __func__, apps_args[0], apps_args[1]);
5489 vosTraceEnable(apps_args[0], apps_args[1]);
5490 }
5491 break;
5492
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005493 case WE_MTRACE_DUMP_CMD:
5494 {
5495 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5496 "bitmask_of_module %d ",
5497 __func__, apps_args[0], apps_args[1], apps_args[2],
5498 apps_args[3]);
5499 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5500 apps_args[2], apps_args[3]);
5501
5502 }
5503 break;
5504
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005505 case WE_MCC_CONFIG_CREDENTIAL :
5506 {
5507 cmd = 287; //Command should be updated if there is any change
5508 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005509 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005510 {
5511 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5512 }
5513 else
5514 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005515 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005516 return 0;
5517 }
5518 }
5519 break;
5520
5521 case WE_MCC_CONFIG_PARAMS :
5522 {
5523 cmd = 288; //command Should be updated if there is any change
5524 // in the Riva dump command
5525 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5526 }
5527 break;
5528
Chilam NG571c65a2013-01-19 12:27:36 +05305529#ifdef FEATURE_WLAN_TDLS
5530 case WE_TDLS_CONFIG_PARAMS :
5531 {
5532 tdls_config_params_t tdlsParams;
5533
Chilam Ng01120412013-02-19 18:32:21 -08005534 tdlsParams.tdls = apps_args[0];
5535 tdlsParams.tx_period_t = apps_args[1];
5536 tdlsParams.tx_packet_n = apps_args[2];
5537 tdlsParams.discovery_period_t = apps_args[3];
5538 tdlsParams.discovery_tries_n = apps_args[4];
5539 tdlsParams.idle_timeout_t = apps_args[5];
5540 tdlsParams.idle_packet_n = apps_args[6];
5541 tdlsParams.rssi_hysteresis = apps_args[7];
5542 tdlsParams.rssi_trigger_threshold = apps_args[8];
5543 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305544
Chilam Ng01120412013-02-19 18:32:21 -08005545 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305546 }
5547 break;
5548#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 default:
5550 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005551 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5552 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 }
5554 break;
5555 }
5556
5557 return 0;
5558}
5559
5560
5561static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5562 union iwreq_data *wrqu, char *extra)
5563{
5564 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5565 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5566 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5567 int params[HDD_WLAN_WMM_PARAM_COUNT];
5568 sme_QosWmmTspecInfo tSpec;
5569 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05305570 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005571
5572 // make sure the application is sufficiently priviledged
5573 // note that the kernel will do this for "set" ioctls, but since
5574 // this ioctl wants to return status to user space it must be
5575 // defined as a "get" ioctl
5576 if (!capable(CAP_NET_ADMIN))
5577 {
5578 return -EPERM;
5579 }
5580
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005581 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5582 {
5583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5584 "%s:LOGP in Progress. Ignore!!!", __func__);
5585 return -EBUSY;
5586 }
5587
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 // we must be associated in order to add a tspec
5589 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5590 {
5591 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5592 return 0;
5593 }
5594
5595 // since we are defined to be a "get" ioctl, and since the number
5596 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05305597 // will pass down in the iwreq_data, we must copy the "set" params.
5598 // We must handle the compat for iwreq_data in 32U/64K environment.
5599
5600 // helper fucntion to get iwreq_data with compat handling.
5601 if (hdd_priv_get_data(&s_priv_data, wrqu))
5602 {
5603 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5604 return 0;
5605 }
5606
5607 // make sure all params are correctly passed to function
5608 if ((NULL == s_priv_data.pointer) ||
5609 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
5610 {
5611 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5612 return 0;
5613 }
5614
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05305616 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 {
5618 // hmmm, can't get them
5619 return -EIO;
5620 }
5621
5622 // clear the tspec
5623 memset(&tSpec, 0, sizeof(tSpec));
5624
5625 // validate the handle
5626 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5627 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5628 {
5629 // that one is reserved
5630 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5631 return 0;
5632 }
5633
5634 // validate the TID
5635 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5636 {
5637 // out of range
5638 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5639 return 0;
5640 }
5641 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5642
5643 // validate the direction
5644 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5645 {
5646 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5647 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5648 break;
5649
5650 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5651 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5652 break;
5653
5654 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5655 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5656 break;
5657
5658 default:
5659 // unknown
5660 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5661 return 0;
5662 }
5663
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305664 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5665
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 // validate the user priority
5667 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5668 {
5669 // out of range
5670 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5671 return 0;
5672 }
5673 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305674 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5675 {
5676 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5677 return 0;
5678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005679
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5681 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5682 tSpec.ts_info.psb, tSpec.ts_info.up);
5683
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5685 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5686 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5687 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5688 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5689 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5690 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5691 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5692 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5693 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5694 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5695 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5696
5697 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5698
5699 // validate the ts info ack policy
5700 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5701 {
5702 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5703 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5704 break;
5705
5706 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5707 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5708 break;
5709
5710 default:
5711 // unknown
5712 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5713 return 0;
5714 }
5715
5716 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5717 return 0;
5718}
5719
5720
5721static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5722 union iwreq_data *wrqu, char *extra)
5723{
5724 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5725 int *params = (int *)extra;
5726 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5727 v_U32_t handle;
5728
5729 // make sure the application is sufficiently priviledged
5730 // note that the kernel will do this for "set" ioctls, but since
5731 // this ioctl wants to return status to user space it must be
5732 // defined as a "get" ioctl
5733 if (!capable(CAP_NET_ADMIN))
5734 {
5735 return -EPERM;
5736 }
5737
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005738 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5739 {
5740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5741 "%s:LOGP in Progress. Ignore!!!", __func__);
5742 return -EBUSY;
5743 }
5744
Jeff Johnson295189b2012-06-20 16:38:30 -07005745 // although we are defined to be a "get" ioctl, the params we require
5746 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5747 // is no need to copy the params from user space
5748
5749 // validate the handle
5750 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5751 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5752 {
5753 // that one is reserved
5754 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5755 return 0;
5756 }
5757
5758 *pStatus = hdd_wmm_delts(pAdapter, handle);
5759 return 0;
5760}
5761
5762
5763static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5764 union iwreq_data *wrqu, char *extra)
5765{
5766 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5767 int *params = (int *)extra;
5768 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5769 v_U32_t handle;
5770
5771 // although we are defined to be a "get" ioctl, the params we require
5772 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5773 // is no need to copy the params from user space
5774
5775 // validate the handle
5776 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5777 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5778 {
5779 // that one is reserved
5780 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5781 return 0;
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 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5792 return 0;
5793}
5794
Jeff Johnson295189b2012-06-20 16:38:30 -07005795#ifdef WLAN_FEATURE_VOWIFI_11R
5796//
5797//
5798// Each time the supplicant has the auth_request or reassoc request
5799// IEs ready. This is pushed to the driver. The driver will inturn use
5800// it to send out the auth req and reassoc req for 11r FT Assoc.
5801//
5802static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5803 union iwreq_data *wrqu, char *extra)
5804{
5805 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5806 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5807 //v_CONTEXT_t pVosContext;
5808
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005809 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5810 {
5811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5812 "%s:LOGP in Progress. Ignore!!!", __func__);
5813 return -EBUSY;
5814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 if (!wrqu->data.length)
5816 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005817 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 return -EINVAL;
5819 }
5820 if (wrqu->data.pointer == NULL)
5821 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005822 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 return -EINVAL;
5824 }
5825
5826 // Added for debug on reception of Re-assoc Req.
5827 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5828 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005829 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005831 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 }
5833
5834#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005835 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005836#endif
5837
5838 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005839 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 wrqu->data.length);
5841
5842 return 0;
5843}
5844#endif
5845
Amar Singhalf3a6e762013-02-19 15:06:50 -08005846static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005847 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005849{
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005851 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005853 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005854 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005855 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5856 int idx;
5857 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005858
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005859 if (pHddCtx->isLogpInProgress)
5860 {
5861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5862 "%s:LOGP in Progress. Ignore!!!", __func__);
5863 return -EBUSY;
5864 }
5865
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305866 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5867 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305868#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005869
Amar Singhalf3a6e762013-02-19 15:06:50 -08005870 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5871 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005872 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005873 hddLog(VOS_TRACE_LEVEL_ERROR,
5874 "%s: vos_mem_alloc failed", __func__);
5875 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005876 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005877
5878 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5879
5880 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5881 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5882
5883 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5884 mc_addr_list_ptr->ulMulticastAddrCnt);
5885
5886 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005887 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005888 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5889 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5890
5891 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5892 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005893 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005894
Amar Singhalf3a6e762013-02-19 15:06:50 -08005895 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5896 vos_mem_free(mc_addr_list_ptr);
5897 if (eHAL_STATUS_SUCCESS != ret_val)
5898 {
5899 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5900 __func__);
5901 return -EINVAL;
5902 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305903#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305904 }
5905 else
5906 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005907
Amar Singhalf3a6e762013-02-19 15:06:50 -08005908 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5909 "%s: Set MC BC Filter Config request: %d suspend %d",
5910 __func__, pRequest->mcastBcastFilterSetting,
5911 pHddCtx->hdd_wlan_suspended);
5912
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305913 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005914
5915 if (pHddCtx->hdd_wlan_suspended)
5916 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005917 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5918 if (NULL == wlanRxpFilterParam)
5919 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305920 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005921 "%s: vos_mem_alloc failed", __func__);
5922 return -EINVAL;
5923 }
5924
Amar Singhalf3a6e762013-02-19 15:06:50 -08005925 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5926 pRequest->mcastBcastFilterSetting;
5927 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5928
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305929 hdd_conf_hostoffload(pAdapter, TRUE);
5930 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5931 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005932
5933 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5934 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305935 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08005936 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5937 wlanRxpFilterParam->setMcstBcstFilter);
5938
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305939 if (eHAL_STATUS_SUCCESS !=
5940 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5941 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08005942 {
5943 hddLog(VOS_TRACE_LEVEL_ERROR,
5944 "%s: Failure to execute set HW MC/BC Filter request",
5945 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005946 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005947 return -EINVAL;
5948 }
5949
Amar Singhalf3a6e762013-02-19 15:06:50 -08005950 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005952
5953 return 0;
5954}
5955
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005956static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005957 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 union iwreq_data *wrqu, char *extra)
5959{
5960 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5961 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305962 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005963 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005964
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305965 //Reset the filter to INI value as we have to clear the dynamic filter
5966 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07005967
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305968 //Configure FW with new setting
5969 if (pHddCtx->hdd_wlan_suspended)
5970 {
5971 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5972 if (NULL == wlanRxpFilterParam)
5973 {
5974 hddLog(VOS_TRACE_LEVEL_ERROR,
5975 "%s: vos_mem_alloc failed", __func__);
5976 return -EINVAL;
5977 }
5978
5979 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5980 pHddCtx->configuredMcastBcastFilter;
5981 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5982
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305983 hdd_conf_hostoffload(pAdapter, TRUE);
5984 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5985 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305986
5987 if (eHAL_STATUS_SUCCESS !=
5988 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5989 wlanRxpFilterParam))
5990 {
5991 hddLog(VOS_TRACE_LEVEL_ERROR,
5992 "%s: Failure to execute set HW MC/BC Filter request",
5993 __func__);
5994 vos_mem_free(wlanRxpFilterParam);
5995 return -EINVAL;
5996 }
5997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 return 0;
5999}
6000
6001static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6002 union iwreq_data *wrqu, char *extra)
6003{
6004 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006005 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 tSirHostOffloadReq offloadRequest;
6007
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006008 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6009 {
6010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6011 "%s:LOGP in Progress. Ignore!!!", __func__);
6012 return -EBUSY;
6013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 /* Debug display of request components. */
6015 switch (pRequest->offloadType)
6016 {
6017 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006018 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 switch (pRequest->enableOrDisable)
6020 {
6021 case WLAN_OFFLOAD_DISABLE:
6022 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6023 break;
6024 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6025 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6026 case WLAN_OFFLOAD_ENABLE:
6027 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6028 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6029 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6030 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6031 }
6032 break;
6033
6034 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006035 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006036 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 switch (pRequest->enableOrDisable)
6038 {
6039 case WLAN_OFFLOAD_DISABLE:
6040 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6041 break;
6042 case WLAN_OFFLOAD_ENABLE:
6043 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6044 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6045 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6046 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6047 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6048 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6049 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6050 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6051 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6052 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6053 }
6054 }
6055
6056 /* Execute offload request. The reason that we can copy the request information
6057 from the ioctl structure to the SME structure is that they are laid out
6058 exactly the same. Otherwise, each piece of information would have to be
6059 copied individually. */
6060 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006061 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6062 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006064 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 __func__);
6066 return -EINVAL;
6067 }
6068
6069 return 0;
6070}
6071
6072static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6073 union iwreq_data *wrqu, char *extra)
6074{
6075 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006076 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 tSirKeepAliveReq keepaliveRequest;
6078
6079 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6080 {
6081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006082 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 return 0;
6084 }
6085
6086 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006087 hddLog(VOS_TRACE_LEVEL_INFO,
6088 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6089 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006090
6091 switch (pRequest->packetType)
6092 {
6093 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006094 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 break;
6096
6097 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6098
Arif Hussain6d2a3322013-11-17 19:50:10 -08006099 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006100 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006101
6102 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6103 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6104 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6105
6106 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6107 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6108 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6109
6110 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6111 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6112 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6113 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6114 break;
6115
6116 }
6117
6118 /* Execute keep alive request. The reason that we can copy the request information
6119 from the ioctl structure to the SME structure is that they are laid out
6120 exactly the same. Otherwise, each piece of information would have to be
6121 copied individually. */
6122 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6123
Arif Hussain6d2a3322013-11-17 19:50:10 -08006124 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006125
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006126 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006127 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006129 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 __func__);
6131 return -EINVAL;
6132 }
6133
6134 return 0;
6135}
6136
6137#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006138int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006139 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006140{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006141 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6142 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 int i=0;
6144
6145 if (pHddCtx->cfg_ini->disablePacketFilter)
6146 {
6147 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006148 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 return 0;
6150 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006151 if (pHddCtx->isLogpInProgress)
6152 {
6153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6154 "%s:LOGP in Progress. Ignore!!!", __func__);
6155 return -EBUSY;
6156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 /* Debug display of request components. */
6158 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006159 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006160
6161 switch (pRequest->filterAction)
6162 {
6163 case HDD_RCV_FILTER_SET:
6164 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006165 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006166
6167 packetFilterSetReq.filterId = pRequest->filterId;
6168 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6169 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006170 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006171 __func__, pRequest->numParams);
6172 return -EINVAL;
6173 }
6174 packetFilterSetReq.numFieldParams = pRequest->numParams;
6175 packetFilterSetReq.coalesceTime = 0;
6176 packetFilterSetReq.filterType = 1;
6177 for (i=0; i < pRequest->numParams; i++)
6178 {
6179 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6180 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6181 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6182 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6183 packetFilterSetReq.paramsData[i].reserved = 0;
6184
Arif Hussain6d2a3322013-11-17 19:50:10 -08006185 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6187 packetFilterSetReq.filterType);
6188
Arif Hussain6d2a3322013-11-17 19:50:10 -08006189 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6191
6192 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6193 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6194 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6195 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6196
Arif Hussain6d2a3322013-11-17 19:50:10 -08006197 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6199 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6200 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6201
Arif Hussain6d2a3322013-11-17 19:50:10 -08006202 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6204 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6205 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6206 }
6207
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006208 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006210 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 __func__);
6212 return -EINVAL;
6213 }
6214
6215 break;
6216
6217 case HDD_RCV_FILTER_CLEAR:
6218
Arif Hussain6d2a3322013-11-17 19:50:10 -08006219 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006220 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006222 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006224 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 __func__);
6226 return -EINVAL;
6227 }
6228 break;
6229
6230 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006231 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006232 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 return -EINVAL;
6234 }
6235 return 0;
6236}
6237
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306238int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6239 tANI_U8 sessionId)
6240{
6241 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6242 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6243
6244 if (NULL == pHddCtx)
6245 {
6246 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6247 return -EINVAL;
6248 }
6249
6250 if (pHddCtx->isLogpInProgress)
6251 {
6252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6253 "%s:LOGP in Progress. Ignore!!!", __func__);
6254 return -EBUSY;
6255 }
6256
6257 if (pHddCtx->cfg_ini->disablePacketFilter)
6258 {
6259 hddLog(VOS_TRACE_LEVEL_ERROR,
6260 "%s: Packet Filtering Disabled. Returning ",
6261 __func__ );
6262 return -EINVAL;
6263 }
6264
6265 switch (filterType)
6266 {
6267 /* For setting IPV6 MC and UC Filter we need to configure
6268 * 2 filters, one for MC and one for UC.
6269 * The Filter ID shouldn't be swapped, which results in making
6270 * UC Filter ineffective.
6271 * We have Hardcode all the values
6272 *
6273 * Reason for a seperate UC filter is because, driver need to
6274 * specify the FW that the specific filter is for unicast
6275 * otherwise FW will not pass the unicast frames by default
6276 * through the filter. This is required to avoid any performance
6277 * hits when no unicast filter is set and only MC/BC are set.
6278 * The way driver informs host is by using the MAC protocol
6279 * layer, CMP flag set to MAX, CMP Data set to 1.
6280 */
6281
6282 case HDD_FILTER_IPV6_MC_UC:
6283 /* Setting IPV6 MC Filter below
6284 */
6285 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6286 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6287 packetFilterSetReq.numFieldParams = 2;
6288 packetFilterSetReq.paramsData[0].protocolLayer =
6289 HDD_FILTER_PROTO_TYPE_MAC;
6290 packetFilterSetReq.paramsData[0].cmpFlag =
6291 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6292 packetFilterSetReq.paramsData[0].dataOffset =
6293 WLAN_HDD_80211_FRM_DA_OFFSET;
6294 packetFilterSetReq.paramsData[0].dataLength = 1;
6295 packetFilterSetReq.paramsData[0].compareData[0] =
6296 HDD_IPV6_MC_CMP_DATA;
6297
6298 packetFilterSetReq.paramsData[1].protocolLayer =
6299 HDD_FILTER_PROTO_TYPE_ARP;
6300 packetFilterSetReq.paramsData[1].cmpFlag =
6301 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6302 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6303 packetFilterSetReq.paramsData[1].dataLength = 2;
6304 packetFilterSetReq.paramsData[1].compareData[0] =
6305 HDD_IPV6_CMP_DATA_0;
6306 packetFilterSetReq.paramsData[1].compareData[1] =
6307 HDD_IPV6_CMP_DATA_1;
6308
6309
6310 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6311 &packetFilterSetReq, sessionId))
6312 {
6313 hddLog(VOS_TRACE_LEVEL_ERROR,
6314 "%s: Failure to execute Set IPv6 Mulicast Filter",
6315 __func__);
6316 return -EINVAL;
6317 }
6318
6319 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6320
6321 /*
6322 * Setting IPV6 UC Filter below
6323 */
6324 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6325 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6326 packetFilterSetReq.numFieldParams = 2;
6327 packetFilterSetReq.paramsData[0].protocolLayer =
6328 HDD_FILTER_PROTO_TYPE_MAC;
6329 packetFilterSetReq.paramsData[0].cmpFlag =
6330 HDD_FILTER_CMP_TYPE_MAX;
6331 packetFilterSetReq.paramsData[0].dataOffset = 0;
6332 packetFilterSetReq.paramsData[0].dataLength = 1;
6333 packetFilterSetReq.paramsData[0].compareData[0] =
6334 HDD_IPV6_UC_CMP_DATA;
6335
6336 packetFilterSetReq.paramsData[1].protocolLayer =
6337 HDD_FILTER_PROTO_TYPE_ARP;
6338 packetFilterSetReq.paramsData[1].cmpFlag =
6339 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6340 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6341 packetFilterSetReq.paramsData[1].dataLength = 2;
6342 packetFilterSetReq.paramsData[1].compareData[0] =
6343 HDD_IPV6_CMP_DATA_0;
6344 packetFilterSetReq.paramsData[1].compareData[1] =
6345 HDD_IPV6_CMP_DATA_1;
6346
6347 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6348 &packetFilterSetReq, sessionId))
6349 {
6350 hddLog(VOS_TRACE_LEVEL_ERROR,
6351 "%s: Failure to execute Set IPv6 Unicast Filter",
6352 __func__);
6353 return -EINVAL;
6354 }
6355
6356 break;
6357
6358 case HDD_FILTER_IPV6_MC:
6359 /*
6360 * IPV6 UC Filter might be already set,
6361 * clear the UC Filter. As the Filter
6362 * IDs are static, we can directly clear it.
6363 */
6364 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6365 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6366 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6367 &packetFilterClrReq, sessionId))
6368 {
6369 hddLog(VOS_TRACE_LEVEL_ERROR,
6370 "%s: Failure to execute Clear IPv6 Unicast Filter",
6371 __func__);
6372 return -EINVAL;
6373 }
6374
6375 /*
6376 * Setting IPV6 MC Filter below
6377 */
6378 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6379 packetFilterSetReq.numFieldParams = 2;
6380 packetFilterSetReq.paramsData[0].protocolLayer =
6381 HDD_FILTER_PROTO_TYPE_MAC;
6382 packetFilterSetReq.paramsData[0].cmpFlag =
6383 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6384 packetFilterSetReq.paramsData[0].dataOffset =
6385 WLAN_HDD_80211_FRM_DA_OFFSET;
6386 packetFilterSetReq.paramsData[0].dataLength = 1;
6387 packetFilterSetReq.paramsData[0].compareData[0] =
6388 HDD_IPV6_MC_CMP_DATA;
6389
6390 packetFilterSetReq.paramsData[1].protocolLayer =
6391 HDD_FILTER_PROTO_TYPE_ARP;
6392 packetFilterSetReq.paramsData[1].cmpFlag =
6393 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6394 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6395 packetFilterSetReq.paramsData[1].dataLength = 2;
6396 packetFilterSetReq.paramsData[1].compareData[0] =
6397 HDD_IPV6_CMP_DATA_0;
6398 packetFilterSetReq.paramsData[1].compareData[1] =
6399 HDD_IPV6_CMP_DATA_1;
6400
6401
6402 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6403 &packetFilterSetReq, sessionId))
6404 {
6405 hddLog(VOS_TRACE_LEVEL_ERROR,
6406 "%s: Failure to execute Set IPv6 Multicast Filter",
6407 __func__);
6408 return -EINVAL;
6409 }
6410 break;
6411
6412 default :
6413 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6414 "%s: Packet Filter Request: Invalid",
6415 __func__);
6416 return -EINVAL;
6417 }
6418 return 0;
6419}
6420
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306421void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006422{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306423 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306424 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006425 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306426 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006427
Yue Ma3ede6052013-08-29 00:33:26 -07006428 if (NULL == pHddCtx)
6429 {
6430 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6431 return;
6432 }
6433
6434 hHal = pHddCtx->hHal;
6435
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306436 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306438 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6439 return;
6440 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306441
6442 /* Check if INI is enabled or not, other wise just return
6443 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306444 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306445 {
6446 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6447 if (NULL == pMulticastAddrs)
6448 {
6449 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6450 return;
6451 }
6452
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 if (set)
6454 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306455 /* Following pre-conditions should be satisfied before wei
6456 * configure the MC address list.
6457 */
6458 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6459 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6460 && pAdapter->mc_addr_list.mc_cnt
6461 && (eConnectionState_Associated ==
6462 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6463 {
6464 pMulticastAddrs->ulMulticastAddrCnt =
6465 pAdapter->mc_addr_list.mc_cnt;
6466 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6467 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006468 memcpy(pMulticastAddrs->multicastAddr[i],
6469 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306470 sizeof(pAdapter->mc_addr_list.addr[i]));
6471 hddLog(VOS_TRACE_LEVEL_INFO,
6472 "%s: %s multicast filter: addr ="
6473 MAC_ADDRESS_STR,
6474 __func__, set ? "setting" : "clearing",
6475 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6476 }
6477 /* Set multicast filter */
6478 sme_8023MulticastList(hHal, pAdapter->sessionId,
6479 pMulticastAddrs);
6480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306482 else
6483 {
6484 /* Need to clear only if it was previously configured
6485 */
6486 if (pAdapter->mc_addr_list.isFilterApplied)
6487 {
6488 pMulticastAddrs->ulMulticastAddrCnt = 0;
6489 sme_8023MulticastList(hHal, pAdapter->sessionId,
6490 pMulticastAddrs);
6491 }
6492
6493 }
6494 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006495 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306497 else
6498 {
6499 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306500 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306501 }
6502 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006503}
6504
6505static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6506 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306507{
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006509 tpPacketFilterCfg pRequest = NULL;
6510 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306511 struct iw_point s_priv_data;
6512
6513 if (hdd_priv_get_data(&s_priv_data, wrqu))
6514 {
6515 return -EINVAL;
6516 }
6517
6518 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6519 {
6520 return -EINVAL;
6521 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006522
Arif Hussain0273cba2014-01-07 20:58:29 -08006523 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306524 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6525 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006526 if (NULL == pRequest)
6527 {
6528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6529 "mem_alloc_copy_from_user_helper fail");
6530 return -ENOMEM;
6531 }
6532
6533 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6534 kfree(pRequest);
6535
6536 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006537}
6538#endif
6539static int iw_get_statistics(struct net_device *dev,
6540 struct iw_request_info *info,
6541 union iwreq_data *wrqu, char *extra)
6542{
6543
6544 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6545 eHalStatus status = eHAL_STATUS_SUCCESS;
6546 hdd_wext_state_t *pWextState;
6547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6548 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6549 char *p = extra;
6550 int tlen = 0;
6551 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6552
6553 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6554 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6555
6556 ENTER();
6557
6558 if (pHddCtx->isLogpInProgress) {
6559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6560 return -EINVAL;
6561 }
6562
6563 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6564
6565 wrqu->txpower.value = 0;
6566 }
6567 else {
6568 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6569 SME_SUMMARY_STATS |
6570 SME_GLOBAL_CLASSA_STATS |
6571 SME_GLOBAL_CLASSB_STATS |
6572 SME_GLOBAL_CLASSC_STATS |
6573 SME_GLOBAL_CLASSD_STATS |
6574 SME_PER_STA_STATS,
6575 hdd_StatisticsCB, 0, FALSE,
6576 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6577
6578 if (eHAL_STATUS_SUCCESS != status)
6579 {
6580 hddLog(VOS_TRACE_LEVEL_ERROR,
6581 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006582 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 return -EINVAL;
6584 }
6585
6586 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6587
6588 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6589 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6590 {
6591 hddLog(VOS_TRACE_LEVEL_ERROR,
6592 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006593 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 /*Remove the SME statistics list by passing NULL in callback argument*/
6595 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6596 SME_SUMMARY_STATS |
6597 SME_GLOBAL_CLASSA_STATS |
6598 SME_GLOBAL_CLASSB_STATS |
6599 SME_GLOBAL_CLASSC_STATS |
6600 SME_GLOBAL_CLASSD_STATS |
6601 SME_PER_STA_STATS,
6602 NULL, 0, FALSE,
6603 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6604
6605 return -EINVAL;
6606 }
6607 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6608 (tANI_U8) sizeof (pStats->retry_cnt),
6609 (char*) &(pStats->retry_cnt[0]),
6610 tlen);
6611
6612 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6613 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6614 (char*) &(pStats->multiple_retry_cnt[0]),
6615 tlen);
6616
6617 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6618 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6619 (char*) &(pStats->tx_frm_cnt[0]),
6620 tlen);
6621
6622 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6623 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6624 (char*) &(pStats->rx_frm_cnt),
6625 tlen);
6626
6627 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6628 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6629 (char*) &(pStats->frm_dup_cnt),
6630 tlen);
6631
6632 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6633 (tANI_U8) sizeof (pStats->fail_cnt),
6634 (char*) &(pStats->fail_cnt[0]),
6635 tlen);
6636
6637 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6638 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6639 (char*) &(pStats->rts_fail_cnt),
6640 tlen);
6641
6642 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6643 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6644 (char*) &(pStats->ack_fail_cnt),
6645 tlen);
6646
6647 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6648 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6649 (char*) &(pStats->rts_succ_cnt),
6650 tlen);
6651
6652 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6653 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6654 (char*) &(pStats->rx_discard_cnt),
6655 tlen);
6656
6657 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6658 (tANI_U8) sizeof (pStats->rx_error_cnt),
6659 (char*) &(pStats->rx_error_cnt),
6660 tlen);
6661
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006662 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006663 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006664 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 tlen);
6666
6667 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6668 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6669 (char*) &(dStats->rx_byte_cnt),
6670 tlen);
6671
6672 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6673 (tANI_U8) sizeof (dStats->rx_rate),
6674 (char*) &(dStats->rx_rate),
6675 tlen);
6676
6677 /* Transmit rate, in units of 500 kbit/sec */
6678 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6679 (tANI_U8) sizeof (aStats->tx_rate),
6680 (char*) &(aStats->tx_rate),
6681 tlen);
6682
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006683 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6684 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6685 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006686 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006687 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6688 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6689 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006690 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006691 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6692 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6693 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006694 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006695 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6696 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6697 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006698 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006699 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6700 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6701 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006702 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006703 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6704 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6705 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006706 tlen);
6707
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 wrqu->data.length = tlen;
6709
6710 }
6711
6712 EXIT();
6713
6714 return 0;
6715}
6716
6717
6718#ifdef FEATURE_WLAN_SCAN_PNO
6719
6720/*Max Len for PNO notification*/
6721#define MAX_PNO_NOTIFY_LEN 100
6722void found_pref_network_cb (void *callbackContext,
6723 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6724{
6725 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6726 union iwreq_data wrqu;
6727 char buf[MAX_PNO_NOTIFY_LEN+1];
6728
6729 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6730 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6731
6732 // create the event
6733 memset(&wrqu, 0, sizeof(wrqu));
6734 memset(buf, 0, sizeof(buf));
6735
6736 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6737 pPrefNetworkFoundInd->ssId.ssId,
6738 (unsigned int)pPrefNetworkFoundInd->rssi);
6739
6740 wrqu.data.pointer = buf;
6741 wrqu.data.length = strlen(buf);
6742
6743 // send the event
6744
6745 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6746
6747}
6748
6749
6750/*string based input*/
6751VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6752 union iwreq_data *wrqu, char *extra, int nOffset)
6753{
6754 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05306755 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006756 /* pnoRequest is a large struct, so we make it static to avoid stack
6757 overflow. This API is only invoked via ioctl, so it is
6758 serialized by the kernel rtnl_lock and hence does not need to be
6759 reentrant */
6760 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 char *ptr;
6762 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05306763 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6765
6766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6767 "PNO data len %d data %s",
6768 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006769 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770
6771 if (wrqu->data.length <= nOffset )
6772 {
6773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6774 return VOS_STATUS_E_FAILURE;
6775 }
6776
6777 pnoRequest.enable = 0;
6778 pnoRequest.ucNetworksCount = 0;
6779 /*-----------------------------------------------------------------------
6780 Input is string based and expected to be like this:
6781
6782 <enabled> <netw_count>
6783 for each network:
6784 <ssid_len> <ssid> <authentication> <encryption>
6785 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6786 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6787
6788 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006789 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 -07006790
6791 this translates into:
6792 -----------------------------
6793 enable PNO
6794 look for 2 networks:
6795 test - with authentication type 0 and encryption type 0,
6796 that can be found on 3 channels: 1 6 and 11 ,
6797 SSID bcast type is unknown (directed probe will be sent if AP not found)
6798 and must meet -40dBm RSSI
6799
6800 test2 - with auth and enrytption type 4/4
6801 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6802 bcast type is non-bcast (directed probe will be sent)
6803 and must not meet any RSSI threshold
6804
Jeff Johnson8301aa12013-03-28 14:27:29 -07006805 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006807 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006808
Wilson Yang623f6592013-10-08 16:33:37 -07006809 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6810 {
6811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6812 "PNO enable input is not valid %s",ptr);
6813 return VOS_STATUS_E_FAILURE;
6814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006815
6816 if ( 0 == pnoRequest.enable )
6817 {
6818 /*Disable PNO*/
6819 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05306820 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
6821 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 pAdapter->sessionId,
6823 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05306824 if (eHAL_STATUS_SUCCESS != status)
6825 {
6826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6827 "%s: failed to disable PNO", __func__);
6828 return VOS_STATUS_E_FAILURE;
6829 }
6830 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 return VOS_STATUS_SUCCESS;
6832 }
6833
c_hpothu37f21312014-04-09 21:49:54 +05306834 if (TRUE == pHddCtx->isPnoEnable)
6835 {
6836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6837 FL("already PNO is enabled"));
6838 return -EBUSY;
6839 }
6840 pHddCtx->isPnoEnable = TRUE;
6841
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006843
6844 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6845 {
6846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6847 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306848 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006850
6851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6852 "PNO enable %d networks count %d offset %d",
6853 pnoRequest.enable,
6854 pnoRequest.ucNetworksCount,
6855 nOffset);
6856
6857 /* Parameters checking:
6858 ucNetworksCount has to be larger than 0*/
6859 if (( 0 == pnoRequest.ucNetworksCount ) ||
6860 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6861 {
6862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05306863 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 }
6865
6866 ptr += nOffset;
6867
6868 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6869 {
6870
6871 pnoRequest.aNetworks[i].ssId.length = 0;
6872
Wilson Yang623f6592013-10-08 16:33:37 -07006873 ucParams = sscanf(ptr,"%hhu %n",
6874 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6875
6876 if (1 != ucParams)
6877 {
6878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6879 "PNO ssid length input is not valid %s",ptr);
6880 return VOS_STATUS_E_FAILURE;
6881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006882
6883 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6884 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6885 {
6886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6887 "SSID Len %d is not correct for network %d",
6888 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05306889 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 }
6891
6892 /*Advance to SSID*/
6893 ptr += nOffset;
6894
Jeff Johnson8301aa12013-03-28 14:27:29 -07006895 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006896 pnoRequest.aNetworks[i].ssId.length);
6897 ptr += pnoRequest.aNetworks[i].ssId.length;
6898
Jeff Johnson02797792013-10-26 19:17:13 -07006899 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006900 &(pnoRequest.aNetworks[i].authentication),
6901 &(pnoRequest.aNetworks[i].encryption),
6902 &(pnoRequest.aNetworks[i].ucChannelCount),
6903 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006904
Wilson Yang623f6592013-10-08 16:33:37 -07006905 if ( 3 != ucParams )
6906 {
6907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6908 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306909 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006910 }
6911
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006913 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006914 "auth %d encry %d channel count %d offset %d",
6915 pnoRequest.aNetworks[i].ssId.length,
6916 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6917 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6918 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6919 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6920 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6921 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6922 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6923 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6924 pnoRequest.aNetworks[i].authentication,
6925 pnoRequest.aNetworks[i].encryption,
6926 pnoRequest.aNetworks[i].ucChannelCount,
6927 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006928
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 /*Advance to channel list*/
6930 ptr += nOffset;
6931
Wilson Yang623f6592013-10-08 16:33:37 -07006932 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 {
6934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6935 "Incorrect number of channels");
6936 return VOS_STATUS_E_FAILURE;
6937 }
6938
6939 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6940 {
6941 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6942 {
Wilson Yang623f6592013-10-08 16:33:37 -07006943 if (1 != sscanf(ptr,"%hhu %n",
6944 &(pnoRequest.aNetworks[i].aChannels[j]),
6945 &nOffset))
6946 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6947 "PNO network channel input is not valid %s",ptr);
6948 return VOS_STATUS_E_FAILURE;
6949 }
6950 /*Advance to next channel number*/
6951 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 }
6953 }
6954
Jeff Johnson02797792013-10-26 19:17:13 -07006955 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006956 &(pnoRequest.aNetworks[i].bcastNetwType),
6957 &nOffset))
6958 {
6959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6960 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306961 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006963
6964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6965 "PNO bcastNetwType %d offset %d",
6966 pnoRequest.aNetworks[i].bcastNetwType,
6967 nOffset );
6968
6969 /*Advance to rssi Threshold*/
6970 ptr += nOffset;
6971
Wilson Yang623f6592013-10-08 16:33:37 -07006972 if (1 != sscanf(ptr,"%hhu %n",
6973 &(pnoRequest.aNetworks[i].rssiThreshold),
6974 &nOffset))
6975 {
6976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6977 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306978 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006980
6981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6982 "PNO rssi %d offset %d",
6983 pnoRequest.aNetworks[i].rssiThreshold,
6984 nOffset );
6985 /*Advance to next network*/
6986 ptr += nOffset;
6987 }/*For ucNetworkCount*/
6988
6989 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07006990 &(pnoRequest.scanTimers.ucScanTimersCount),
6991 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006992
6993 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07006994 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 {
6996 ptr += nOffset;
6997
Jeff Johnson8301aa12013-03-28 14:27:29 -07006998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6999 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 pnoRequest.scanTimers.ucScanTimersCount,
7001 nOffset );
7002
7003 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7004 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307007 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 }
7009
7010 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7011 {
Jeff Johnson02797792013-10-26 19:17:13 -07007012 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7014 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7015 &nOffset);
7016
Wilson Yang623f6592013-10-08 16:33:37 -07007017 if (2 != ucParams)
7018 {
7019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7020 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307021 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007022 }
7023
Jeff Johnson8301aa12013-03-28 14:27:29 -07007024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7025 "PNO Timer value %d Timer repeat %d offset %d",
7026 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7028 nOffset );
7029
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 ptr += nOffset;
7031 }
7032
7033 }
7034 else
7035 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7037 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7039
7040 /*Scan timers defaults to 5 minutes*/
7041 pnoRequest.scanTimers.ucScanTimersCount = 1;
7042 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7043 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7044 }
7045
Wilson Yang623f6592013-10-08 16:33:37 -07007046 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007047
7048 pnoRequest.modePNO = ucMode;
7049 /*for LA we just expose suspend option*/
7050 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7051 {
7052 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7053 }
7054
c_hpothu37f21312014-04-09 21:49:54 +05307055 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 pAdapter->sessionId,
7057 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307058 if (eHAL_STATUS_SUCCESS == status)
7059 {
7060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7061 "%s: PNO enabled", __func__);
7062 return VOS_STATUS_SUCCESS;
7063 }
7064error:
7065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7066 "%s: Failed to enable PNO", __func__);
7067 pHddCtx->isPnoEnable = FALSE;
7068 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007069}/*iw_set_pno*/
7070
7071VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7072 union iwreq_data *wrqu, char *extra, int nOffset)
7073{
7074 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7075 v_U8_t rssiThreshold = 0;
7076 v_U8_t nRead;
7077
Arif Hussain7adce1b2013-11-11 22:59:34 -08007078 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 &rssiThreshold);
7080
7081 if ( 1 != nRead )
7082 {
7083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7084 "Incorrect format");
7085 return VOS_STATUS_E_FAILURE;
7086 }
7087
7088 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7089 return VOS_STATUS_SUCCESS;
7090}
7091
7092
7093static int iw_set_pno_priv(struct net_device *dev,
7094 struct iw_request_info *info,
7095 union iwreq_data *wrqu, char *extra)
7096{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7098
7099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007101
7102 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7103 {
7104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7105 "%s:LOGP in Progress. Ignore!!!", __func__);
7106 return -EBUSY;
7107 }
7108 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007109}
7110#endif /*FEATURE_WLAN_SCAN_PNO*/
7111
7112//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307113int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007114{
7115 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7116 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7117 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307118 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307120 eCsrBand connectedBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007121
Atul Mittal54378cb2014-04-02 16:51:50 +05307122 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 {
7124 case WLAN_HDD_UI_BAND_AUTO:
7125 band = eCSR_BAND_ALL;
7126 break;
7127 case WLAN_HDD_UI_BAND_5_GHZ:
7128 band = eCSR_BAND_5G;
7129 break;
7130 case WLAN_HDD_UI_BAND_2_4_GHZ:
7131 band = eCSR_BAND_24;
7132 break;
7133 default:
7134 band = eCSR_BAND_MAX;
7135 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307136 connectedBand =
7137 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007138
Atul Mittal54378cb2014-04-02 16:51:50 +05307139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007140 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007141
7142 if (band == eCSR_BAND_MAX)
7143 {
7144 /* Received change band request with invalid band value */
7145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307146 "%s: Invalid band value %u", __func__, ui_band);
7147 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 }
7149
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307150 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7151 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7152 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7153 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007155 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007156 band, pHddCtx->cfg_ini->nBandCapability);
7157 return -EIO;
7158 }
7159
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7161 {
7162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7163 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007164 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 return -EIO;
7166 }
7167
7168 if (currBand != band)
7169 {
7170 /* Change band request received.
7171 * Abort pending scan requests, flush the existing scan results,
7172 * and change the band capability
7173 */
7174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7175 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007176 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007177
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307178 /* We need to change the band and flush the scan results here itself
7179 * as we may get timeout for disconnection in which we will return
7180 * with out doing any of these
7181 */
7182 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7183 {
7184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7185 "%s: failed to set the band value to %u ",
7186 __func__, band);
7187 return -EINVAL;
7188 }
7189 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7190 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7191 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7192 sme_FilterScanResults(hHal, pAdapter->sessionId);
7193
7194 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307195 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7196 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 {
7198 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7199 eHalStatus status = eHAL_STATUS_SUCCESS;
7200 long lrc;
7201
7202 /* STA already connected on current band, So issue disconnect first,
7203 * then change the band*/
7204
7205 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05307206 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
7207 " Set HDD connState to eConnectionState_NotConnected",
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 __func__, csrGetCurrentBand(hHal), band);
7209
7210 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7211 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7212
7213 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7214 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7215
Jeff Johnson43971f52012-07-17 12:26:56 -07007216 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 {
7218 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007219 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 __func__, (int)status );
7221 return -EINVAL;
7222 }
7223
7224 lrc = wait_for_completion_interruptible_timeout(
7225 &pAdapter->disconnect_comp_var,
7226 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7227
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307228 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007229
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007230 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007231 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007232
7233 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7234 }
7235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 }
7237 return 0;
7238}
7239
Atul Mittal54378cb2014-04-02 16:51:50 +05307240int hdd_setBand_helper(struct net_device *dev, const char *command)
7241{
7242 u8 band;
7243
7244 /*convert the band value from ascii to integer*/
7245 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7246
7247 return hdd_setBand(dev, band);
7248
7249}
7250
Jeff Johnson295189b2012-06-20 16:38:30 -07007251static int iw_set_band_config(struct net_device *dev,
7252 struct iw_request_info *info,
7253 union iwreq_data *wrqu, char *extra)
7254{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007255 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307256 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007257
Arif Hussain0273cba2014-01-07 20:58:29 -08007258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007259
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007260 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7261 {
7262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7263 "%s:LOGP in Progress. Ignore!!!", __func__);
7264 return -EBUSY;
7265 }
7266
Atul Mittal54378cb2014-04-02 16:51:50 +05307267 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007268}
7269
7270static int iw_set_power_params_priv(struct net_device *dev,
7271 struct iw_request_info *info,
7272 union iwreq_data *wrqu, char *extra)
7273{
Arif Hussain0273cba2014-01-07 20:58:29 -08007274 int ret;
7275 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7277 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007278 /* ODD number is used for set, copy data using copy_from_user */
7279 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7280 wrqu->data.length);
7281 if (NULL == ptr)
7282 {
7283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7284 "mem_alloc_copy_from_user_helper fail");
7285 return -ENOMEM;
7286 }
7287
7288 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7289 kfree(ptr);
7290 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007291}
7292
7293
7294
7295/*string based input*/
7296VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7297 union iwreq_data *wrqu, char *extra, int nOffset)
7298{
7299 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7300 tSirSetPowerParamsReq powerRequest;
7301 char *ptr;
7302 v_U8_t ucType;
7303 v_U32_t uTotalSize, uValue;
7304 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7305
7306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7307 "Power Params data len %d data %s",
7308 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007309 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007310
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007311 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7312 {
7313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7314 "%s:LOGP in Progress. Ignore!!!", __func__);
7315 return -EBUSY;
7316 }
7317
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 if (wrqu->data.length <= nOffset )
7319 {
7320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7321 return VOS_STATUS_E_FAILURE;
7322 }
7323
7324 uTotalSize = wrqu->data.length - nOffset;
7325
7326 /*-----------------------------------------------------------------------
7327 Input is string based and expected to be like this:
7328
7329 <param_type> <param_value> <param_type> <param_value> ...
7330
7331 e.g:
7332 1 2 2 3 3 0 4 1 5 1
7333
7334 e.g. setting just a few:
7335 1 2 4 1
7336
7337 parameter types:
7338 -----------------------------
7339 1 - Ignore DTIM
7340 2 - Listen Interval
7341 3 - Broadcast Multicas Filter
7342 4 - Beacon Early Termination
7343 5 - Beacon Early Termination Interval
7344 -----------------------------------------------------------------------*/
7345 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7346 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7347 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7348 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7349 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7350
Arif Hussain7adce1b2013-11-11 22:59:34 -08007351 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007352
7353 while ( uTotalSize )
7354 {
Wilson Yang6f971452013-10-08 15:00:00 -07007355 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7356 {
7357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7358 "Invalid input parameter type %s",ptr);
7359 return VOS_STATUS_E_FAILURE;
7360 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007361
7362 uTotalSize -= nOffset;
7363
7364 if (!uTotalSize)
7365 {
7366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007367 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 ucType, nOffset);
7369 return VOS_STATUS_E_FAILURE;
7370 }
7371
7372 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007373
Jeff Johnson02797792013-10-26 19:17:13 -07007374 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007375 {
7376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7377 "Invalid input parameter value %s",ptr);
7378 return VOS_STATUS_E_FAILURE;
7379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007380
7381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7382 "Power request parameter %d value %d offset %d",
7383 ucType, uValue, nOffset);
7384
7385 switch (ucType)
7386 {
7387 case eSIR_IGNORE_DTIM:
7388 powerRequest.uIgnoreDTIM = uValue;
7389 break;
7390 case eSIR_LISTEN_INTERVAL:
7391 powerRequest.uListenInterval = uValue;
7392 break;
7393 case eSIR_MCAST_BCAST_FILTER:
7394 powerRequest.uBcastMcastFilter = uValue;
7395 break;
7396 case eSIR_ENABLE_BET:
7397 powerRequest.uEnableBET = uValue;
7398 break;
7399 case eSIR_BET_INTERVAL:
7400 powerRequest.uBETInterval = uValue;
7401 break;
7402 default:
7403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007404 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 ucType, uValue, nOffset);
7406 return VOS_STATUS_E_FAILURE;
7407 }
7408
7409 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7411 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007412 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007414 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007415 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007416 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7417 {
7418 uTotalSize = 0;
7419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007420
7421 }/*Go for as long as we have a valid string*/
7422
7423 /* put the device into full power*/
7424 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7425
7426 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007427 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
7429 /* put the device back to power save*/
7430 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7431
7432 return VOS_STATUS_SUCCESS;
7433}/*iw_set_power_params*/
7434
7435
7436// Define the Wireless Extensions to the Linux Network Device structure
7437// A number of these routines are NULL (meaning they are not implemented.)
7438
7439static const iw_handler we_handler[] =
7440{
7441 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7442 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7443 (iw_handler) NULL, /* SIOCSIWNWID */
7444 (iw_handler) NULL, /* SIOCGIWNWID */
7445 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7446 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7447 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7448 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7449 (iw_handler) NULL, /* SIOCSIWSENS */
7450 (iw_handler) NULL, /* SIOCGIWSENS */
7451 (iw_handler) NULL, /* SIOCSIWRANGE */
7452 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7453 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7454 (iw_handler) NULL, /* SIOCGIWPRIV */
7455 (iw_handler) NULL, /* SIOCSIWSTATS */
7456 (iw_handler) NULL, /* SIOCGIWSTATS */
7457 iw_handler_set_spy, /* SIOCSIWSPY */
7458 iw_handler_get_spy, /* SIOCGIWSPY */
7459 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7460 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7461 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7462 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7463 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7464 (iw_handler) NULL, /* SIOCGIWAPLIST */
7465 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7466 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7467 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7468 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7469 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7470 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7471 (iw_handler) NULL, /* -- hole -- */
7472 (iw_handler) NULL, /* -- hole -- */
7473 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7474 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7475 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7476 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7477 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7478 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7479 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7480 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7481 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7482 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7483 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7484 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7485 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7486 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7487 (iw_handler) NULL, /* -- hole -- */
7488 (iw_handler) NULL, /* -- hole -- */
7489 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7490 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7491 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7492 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7493 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7494 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7495 (iw_handler) NULL, /* SIOCSIWPMKSA */
7496};
7497
7498static const iw_handler we_private[] = {
7499
7500 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7501 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7502 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7503 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7504 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7505 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7506 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7507 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7508 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7509 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007510#ifdef FEATURE_OEM_DATA_SUPPORT
7511 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7512 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7513#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007514
Jeff Johnson295189b2012-06-20 16:38:30 -07007515#ifdef WLAN_FEATURE_VOWIFI_11R
7516 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7517#endif
7518 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7519 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7520 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7521#ifdef WLAN_FEATURE_PACKET_FILTERING
7522 ,
7523 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7524#endif
7525#ifdef FEATURE_WLAN_SCAN_PNO
7526 ,
7527 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7528#endif
7529 ,
7530 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7531 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7532 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7533 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007534 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007535};
7536
7537/*Maximum command length can be only 15 */
7538static const struct iw_priv_args we_private_args[] = {
7539
7540 /* handlers for main ioctl */
7541 { WLAN_PRIV_SET_INT_GET_NONE,
7542 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7543 0,
7544 "" },
7545
7546 /* handlers for sub-ioctl */
7547 { WE_SET_11D_STATE,
7548 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7549 0,
7550 "set11Dstate" },
7551
7552 { WE_WOWL,
7553 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7554 0,
7555 "wowl" },
7556
7557 { WE_SET_POWER,
7558 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7559 0,
7560 "setPower" },
7561
7562 { WE_SET_MAX_ASSOC,
7563 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7564 0,
7565 "setMaxAssoc" },
7566
7567 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7568 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7569 0,
7570 "setAutoChannel" },
7571
7572 { WE_SET_DATA_INACTIVITY_TO,
7573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7574 0,
7575 "inactivityTO" },
7576
7577 { WE_SET_MAX_TX_POWER,
7578 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7579 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007580 "setMaxTxPower" },
7581
7582 { WE_SET_MAX_TX_POWER_2_4,
7583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7584 0,
7585 "setTxMaxPower2G" },
7586
7587 { WE_SET_MAX_TX_POWER_5_0,
7588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7589 0,
7590 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007591
7592 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7593 * as well to keep same syntax as in SAP. Now onwards, STA
7594 * will support both */
7595 { WE_SET_MAX_TX_POWER,
7596 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7597 0,
7598 "setTxMaxPower" },
7599
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7601 * 1 = enable and 0 = disable */
7602 {
7603 WE_SET_HIGHER_DTIM_TRANSITION,
7604 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7605 0,
7606 "setHDtimTransn" },
7607
7608 { WE_SET_TM_LEVEL,
7609 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007610 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007611 "setTmLevel" },
7612
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307613 { WE_ENABLE_STRICT_FCC_REG,
7614 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7615 0,
7616 "setStrictFCCreg" },
7617
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007618 { WE_SET_DEBUG_LOG,
7619 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7620 0, "setDbgLvl" },
7621
Jeff Johnson295189b2012-06-20 16:38:30 -07007622 /* handlers for main ioctl */
7623 { WLAN_PRIV_SET_NONE_GET_INT,
7624 0,
7625 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7626 "" },
7627
7628 /* handlers for sub-ioctl */
7629 { WE_GET_11D_STATE,
7630 0,
7631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7632 "get11Dstate" },
7633
7634 { WE_IBSS_STATUS,
7635 0,
7636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7637 "getAdhocStatus" },
7638
7639 { WE_PMC_STATE,
7640 0,
7641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7642 "pmcState" },
7643
7644 { WE_GET_WLAN_DBG,
7645 0,
7646 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7647 "getwlandbg" },
7648
7649 { WE_MODULE_DOWN_IND,
7650 0,
7651 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7652 "moduleDownInd" },
7653
7654 { WE_GET_MAX_ASSOC,
7655 0,
7656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7657 "getMaxAssoc" },
7658
Jeff Johnson295189b2012-06-20 16:38:30 -07007659 { WE_GET_WDI_DBG,
7660 0,
7661 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7662 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007663
7664 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7665 0,
7666 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7667 "getAutoChannel" },
7668
7669 { WE_GET_CONCURRENCY_MODE,
7670 0,
7671 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7672 "getconcurrency" },
7673
7674 /* handlers for main ioctl */
7675 { WLAN_PRIV_SET_CHAR_GET_NONE,
7676 IW_PRIV_TYPE_CHAR| 512,
7677 0,
7678 "" },
7679
7680 /* handlers for sub-ioctl */
7681 { WE_WOWL_ADD_PTRN,
7682 IW_PRIV_TYPE_CHAR| 512,
7683 0,
7684 "wowlAddPtrn" },
7685
7686 { WE_WOWL_DEL_PTRN,
7687 IW_PRIV_TYPE_CHAR| 512,
7688 0,
7689 "wowlDelPtrn" },
7690
7691#if defined WLAN_FEATURE_VOWIFI
7692 /* handlers for sub-ioctl */
7693 { WE_NEIGHBOR_REPORT_REQUEST,
7694 IW_PRIV_TYPE_CHAR | 512,
7695 0,
7696 "neighbor" },
7697#endif
7698 { WE_SET_AP_WPS_IE,
7699 IW_PRIV_TYPE_CHAR| 512,
7700 0,
7701 "set_ap_wps_ie" },
7702
7703 { WE_SET_CONFIG,
7704 IW_PRIV_TYPE_CHAR| 512,
7705 0,
7706 "setConfig" },
7707
7708 /* handlers for main ioctl */
7709 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7711 0,
7712 "" },
7713
7714 /* handlers for sub-ioctl */
7715 { WE_SET_WLAN_DBG,
7716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7717 0,
7718 "setwlandbg" },
7719
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 { WE_SET_WDI_DBG,
7721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7722 0,
7723 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007724
7725 { WE_SET_SAP_CHANNELS,
7726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7727 0,
7728 "setsapchannels" },
7729
7730 /* handlers for main ioctl */
7731 { WLAN_PRIV_GET_CHAR_SET_NONE,
7732 0,
7733 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7734 "" },
7735
7736 /* handlers for sub-ioctl */
7737 { WE_WLAN_VERSION,
7738 0,
7739 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7740 "version" },
7741 { WE_GET_STATS,
7742 0,
7743 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7744 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307745 { WE_GET_STATES,
7746 0,
7747 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7748 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007749 { WE_GET_CFG,
7750 0,
7751 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7752 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007753#ifdef WLAN_FEATURE_11AC
7754 { WE_GET_RSSI,
7755 0,
7756 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7757 "getRSSI" },
7758#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007759#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007760 { WE_GET_ROAM_RSSI,
7761 0,
7762 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7763 "getRoamRSSI" },
7764#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007765 { WE_GET_WMM_STATUS,
7766 0,
7767 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7768 "getWmmStatus" },
7769 {
7770 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307771 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007772 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7773 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007774#ifdef FEATURE_WLAN_TDLS
7775 {
7776 WE_GET_TDLS_PEERS,
7777 0,
7778 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7779 "getTdlsPeers" },
7780#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007781#ifdef WLAN_FEATURE_11W
7782 {
7783 WE_GET_11W_INFO,
7784 0,
7785 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7786 "getPMFInfo" },
7787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007788 /* handlers for main ioctl */
7789 { WLAN_PRIV_SET_NONE_GET_NONE,
7790 0,
7791 0,
7792 "" },
7793
7794 /* handlers for sub-ioctl */
7795 { WE_CLEAR_STATS,
7796 0,
7797 0,
7798 "clearStats" },
7799 { WE_INIT_AP,
7800 0,
7801 0,
7802 "initAP" },
7803 { WE_STOP_AP,
7804 0,
7805 0,
7806 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +05307807#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 { WE_ENABLE_AMP,
7809 0,
7810 0,
7811 "enableAMP" },
7812 { WE_DISABLE_AMP,
7813 0,
7814 0,
7815 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +05307816#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007817 { WE_ENABLE_DXE_STALL_DETECT,
7818 0,
7819 0,
7820 "dxeStallDetect" },
7821 { WE_DISPLAY_DXE_SNAP_SHOT,
7822 0,
7823 0,
7824 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307825 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
7826 0,
7827 0,
7828 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07007829 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307830 WE_SET_REASSOC_TRIGGER,
7831 0,
7832 0,
7833 "reassoc" },
7834 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307835 WE_STOP_OBSS_SCAN,
7836 0,
7837 0,
7838 "stopOBSSScan" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007839
7840 /* handlers for main ioctl */
7841 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
7842 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7843 0,
7844 "" },
7845
7846 /* handlers for sub-ioctl */
7847 { WE_LOG_DUMP_CMD,
7848 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7849 0,
7850 "dump" },
7851
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007852 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307853 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
7854 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7855 0,
7856 "setdumplog" },
7857
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007858 { WE_MTRACE_DUMP_CMD,
7859 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7860 0,
7861 "dumplog" },
7862
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007863 /* handlers for sub ioctl */
7864 {
7865 WE_MCC_CONFIG_CREDENTIAL,
7866 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7867 0,
7868 "setMccCrdnl" },
7869
7870 /* handlers for sub ioctl */
7871 {
7872 WE_MCC_CONFIG_PARAMS,
7873 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7874 0,
7875 "setMccConfig" },
7876
Chilam NG571c65a2013-01-19 12:27:36 +05307877#ifdef FEATURE_WLAN_TDLS
7878 /* handlers for sub ioctl */
7879 {
7880 WE_TDLS_CONFIG_PARAMS,
7881 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
7882 0,
7883 "setTdlsConfig" },
7884#endif
7885
Jeff Johnson295189b2012-06-20 16:38:30 -07007886 /* handlers for main ioctl */
7887 { WLAN_PRIV_ADD_TSPEC,
7888 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
7889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7890 "addTspec" },
7891
7892 /* handlers for main ioctl */
7893 { WLAN_PRIV_DEL_TSPEC,
7894 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7895 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7896 "delTspec" },
7897
7898 /* handlers for main ioctl */
7899 { WLAN_PRIV_GET_TSPEC,
7900 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7901 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7902 "getTspec" },
7903
Jeff Johnsone7245742012-09-05 17:12:55 -07007904#ifdef FEATURE_OEM_DATA_SUPPORT
7905 /* handlers for main ioctl - OEM DATA */
7906 {
7907 WLAN_PRIV_SET_OEM_DATA_REQ,
7908 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
7909 0,
7910 "set_oem_data_req" },
7911
7912 /* handlers for main ioctl - OEM DATA */
7913 {
7914 WLAN_PRIV_GET_OEM_DATA_RSP,
7915 0,
7916 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
7917 "get_oem_data_rsp" },
7918#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007919
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 /* handlers for main ioctl - host offload */
7921 {
7922 WLAN_PRIV_SET_HOST_OFFLOAD,
7923 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
7924 0,
7925 "setHostOffload" },
7926
7927 {
7928 WLAN_GET_WLAN_STATISTICS,
7929 0,
7930 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
7931 "getWlanStats" },
7932
7933 {
7934 WLAN_SET_KEEPALIVE_PARAMS,
7935 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
7936 0,
7937 "setKeepAlive" },
7938#ifdef WLAN_FEATURE_PACKET_FILTERING
7939 {
7940 WLAN_SET_PACKET_FILTER_PARAMS,
7941 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
7942 0,
7943 "setPktFilter" },
7944#endif
7945#ifdef FEATURE_WLAN_SCAN_PNO
7946 {
7947 WLAN_SET_PNO,
7948 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7949 0,
7950 "setpno" },
7951#endif
7952 {
7953 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05307954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 0,
7956 "SETBAND" },
7957 /* handlers for dynamic MC BC ioctl */
7958 {
7959 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007960 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 0,
7962 "setMCBCFilter" },
7963 {
7964 WLAN_PRIV_CLEAR_MCBC_FILTER,
7965 0,
7966 0,
7967 "clearMCBCFilter" },
7968 {
7969 WLAN_SET_POWER_PARAMS,
7970 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7971 0,
7972 "setpowerparams" },
7973 {
7974 WLAN_GET_LINK_SPEED,
7975 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05307976 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007977};
7978
7979
7980
7981const struct iw_handler_def we_handler_def = {
7982 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
7983 .num_private = sizeof(we_private) / sizeof(we_private[0]),
7984 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
7985
7986 .standard = (iw_handler *)we_handler,
7987 .private = (iw_handler *)we_private,
7988 .private_args = we_private_args,
7989 .get_wireless_stats = get_wireless_stats,
7990};
7991
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007992int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
7993{
7994 v_U32_t cmd = 288; //Command to RIVA
7995 hdd_context_t *pHddCtx = NULL;
7996 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7997 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7998 /*
7999 *configMccParam : specify the bit which needs to be modified
8000 *allowed to update based on wlan_qcom_cfg.ini
8001 * configuration
8002 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8003 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8004 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8005 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8006 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8007 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8008 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8009 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8010 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8011 * Bit 9 : Reserved
8012 */
8013 switch (arg1)
8014 {
8015 //Update MCC SCHEDULE_TIME_SLICE parameter
8016 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8017 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8018 {
8019 if((arg2 >= 5) && (arg2 <= 20))
8020 {
8021 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8022 }
8023 else
8024 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008025 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008026 return 0;
8027 }
8028 }
8029 break;
8030
8031 //Update MCC MAX_NULL_SEND_TIME parameter
8032 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8033 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8034 {
8035 if((arg2 >= 1) && (arg2 <= 10))
8036 {
8037 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8038 }
8039 else
8040 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008041 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008042 return 0;
8043 }
8044 }
8045 break;
8046
8047 //Update MCC TX_EARLY_STOP_TIME parameter
8048 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8049 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8050 {
8051 if((arg2 >= 1) && (arg2 <= 10))
8052 {
8053 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8054 }
8055 else
8056 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008057 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008058 return 0;
8059 }
8060 }
8061 break;
8062
8063 //Update MCC RX_DRAIN_TIME parameter
8064 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8065 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8066 {
8067 if((arg2 >= 1) && (arg2 <= 10))
8068 {
8069 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8070 }
8071 else
8072 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008073 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008074 return 0;
8075 }
8076 }
8077 break;
8078
8079 //Update MCC CHANNEL_SWITCH_TIME parameter
8080 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8081 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8082 {
8083 if((arg2 >= 1) && (arg2 <= 20))
8084 {
8085 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8086 }
8087 else
8088 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008089 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008090 return 0;
8091 }
8092 }
8093 break;
8094
8095 //Update MCC MIN_CHANNEL_TIME parameter
8096 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8097 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8098 {
8099 if((arg2 >= 5) && (arg2 <= 20))
8100 {
8101 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8102 }
8103 else
8104 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008105 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008106 return 0;
8107 }
8108 }
8109 break;
8110
8111 //Update MCC PARK_BEFORE_TBTT parameter
8112 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8113 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8114 {
8115 if((arg2 >= 1) && (arg2 <= 5))
8116 {
8117 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8118 }
8119 else
8120 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008121 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008122 return 0;
8123 }
8124 }
8125 break;
8126
8127 //Update MCC MIN_AFTER_DTIM parameter
8128 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8129 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8130 {
8131 if((arg2 >= 5) && (arg2 <= 15))
8132 {
8133 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8134 }
8135 else
8136 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008137 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008138 return 0;
8139 }
8140 }
8141 break;
8142
8143 //Update MCC TOO_CLOSE_MARGIN parameter
8144 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8145 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8146 {
8147 if((arg2 >= 1) && (arg2 <= 3))
8148 {
8149 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8150 }
8151 else
8152 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008153 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008154 return 0;
8155 }
8156 }
8157 break;
8158
8159 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008160 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008161 __FUNCTION__,arg1);
8162 break;
8163 }
8164 return 0;
8165}
8166
Jeff Johnson295189b2012-06-20 16:38:30 -07008167int hdd_set_wext(hdd_adapter_t *pAdapter)
8168{
8169 hdd_wext_state_t *pwextBuf;
8170 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008171 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008172
8173 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8174
8175 // Now configure the roaming profile links. To SSID and bssid.
8176 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8177 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8178
8179 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8180 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8181
8182 /*Set the numOfChannels to zero to scan all the channels*/
8183 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8184 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8185
8186 /* Default is no encryption */
8187 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8188 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8189
8190 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8191 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8192
8193 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8194
8195 /* Default is no authentication */
8196 pwextBuf->roamProfile.AuthType.numEntries = 1;
8197 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8198
8199 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8200 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8201
8202 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008203 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008204
8205 hdd_clearRoamProfileIe(pAdapter);
8206
8207 return VOS_STATUS_SUCCESS;
8208
8209 }
8210
8211int hdd_register_wext(struct net_device *dev)
8212 {
8213 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8214 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8215 VOS_STATUS status;
8216
8217 ENTER();
8218
8219 // Zero the memory. This zeros the profile structure.
8220 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8221
8222 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8223
8224
8225 status = hdd_set_wext(pAdapter);
8226
8227 if(!VOS_IS_STATUS_SUCCESS(status)) {
8228
Arif Hussain6d2a3322013-11-17 19:50:10 -08008229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 return eHAL_STATUS_FAILURE;
8231 }
8232
8233 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8234 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 return eHAL_STATUS_FAILURE;
8237 }
8238
8239 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8240 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 return eHAL_STATUS_FAILURE;
8243 }
8244
8245 // Register as a wireless device
8246 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8247
8248 EXIT();
8249 return 0;
8250}
8251
8252int hdd_UnregisterWext(struct net_device *dev)
8253{
8254#if 0
8255 hdd_wext_state_t *wextBuf;
8256 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8257
8258 ENTER();
8259 // Set up the pointer to the Wireless Extensions state structure
8260 wextBuf = pAdapter->pWextState;
8261
8262 // De-allocate the Wireless Extensions state structure
8263 kfree(wextBuf);
8264
8265 // Clear out the pointer to the Wireless Extensions state structure
8266 pAdapter->pWextState = NULL;
8267
8268 EXIT();
8269#endif
8270 dev->wireless_handlers = NULL;
8271 return 0;
8272}
8273
8274